#29768: Confusing error when AppConfig subclass's name is misspelled
------------------------------------------------+------------------------
               Reporter:  Marten Kenbeek        |          Owner:  (none)
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Error reporting       |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  1
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 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

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29768>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/047.081c603ca559a03b7543af34e8a4963c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to