Opened 6 years ago

Closed 6 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 Carlton Gibson, 6 years ago

Triage Stage: UnreviewedAccepted

Yep. That sounds helpful/reasonable. (Certainly worth looking at a PR at any rate. 🙂)

Last edited 6 years ago by Carlton Gibson (previous) (diff)

comment:2 by Marten Kenbeek, 6 years ago

Has patch: set
Owner: set to Marten Kenbeek
Status: newassigned
Last edited 6 years ago by Tim Graham (previous) (diff)

comment:3 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 40c8ffad:

Fixed #29768 -- Improved error message when an AppConfig has a typo in INSTALLED_APPS.

Note: See TracTickets for help on using tickets.
Back to Top