[Django] #29768: Confusing error when AppConfig subclass's name is misspelled

6 views
Skip to first unread message

Django

unread,
Sep 18, 2018, 6:17:20 AM9/18/18
to django-...@googlegroups.com
#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.

Django

unread,
Sep 18, 2018, 6:22:30 AM9/18/18
to django-...@googlegroups.com
#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 | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/29768#comment:1>

Django

unread,
Sep 18, 2018, 12:54:05 PM9/18/18
to django-...@googlegroups.com
#29768: Confusing error when AppConfig subclass's name is misspelled
-------------------------------------+-------------------------------------
Reporter: Marten Kenbeek | Owner: Marten
Type: | Kenbeek
Cleanup/optimization | Status: assigned

Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Marten Kenbeek):

* owner: (none) => Marten Kenbeek
* status: new => assigned
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29768#comment:2>

Django

unread,
Sep 26, 2018, 5:10:02 PM9/26/18
to django-...@googlegroups.com
#29768: Confusing error when AppConfig subclass's name is misspelled
-------------------------------------+-------------------------------------
Reporter: Marten Kenbeek | Owner: Marten
Type: | Kenbeek
Cleanup/optimization | Status: closed

Component: Error reporting | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"40c8ffad7249fd37ca1629f06d3ab6b129d84b21" 40c8ffad]:
{{{
#!CommitTicketReference repository=""
revision="40c8ffad7249fd37ca1629f06d3ab6b129d84b21"
Fixed #29768 -- Improved error message when an AppConfig has a typo in
INSTALLED_APPS.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29768#comment:3>

Reply all
Reply to author
Forward
0 new messages