Opened 7 years ago
Closed 7 years ago
#29768 closed Cleanup/optimization (fixed)
Confusing error when AppConfig subclass's name is misspelled
| Reported by: | Marten Kenbeek | Owned by: | Marten Kenbeek |
|---|---|---|---|
| Component: | Error reporting | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
When you misspell the name of the AppConfig subclass in INSTALLED_APPS, it currently retriggers the exception for importing the class as a module[1]. This disregards that the mod_path (all but the last part of the import string) is importable and defines an AppConfig subclass.
In my case, I had a config at courses.apps.CoursesConfig, and included 'courses.apps.CourseConfig' (no 's' in Courses) in INSTALLED_APPS.
I think we can provide a better error message when the mod_path (courses.apps) is importable and has AppConfig subclasses, something like "'courses.apps' does not have a class 'CourseConfig', did you mean 'CoursesConfig'?".
[1] https://github.com/django/django/blob/0c20850774e1ba2f408745916e2279592999ee98/django/apps/config.py#L123
Change History (3)
comment:1 by , 7 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 7 years ago
| Has patch: | set |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
Yep. That sounds helpful/reasonable. (Certainly worth looking at a PR at any rate. 🙂)