#25381 closed Bug (invalid)
"default_app_config" causes custom commands to not be found
Reported by: | Greg Ziegan | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Not entirely sure if this is just an environment issue but I've been able to reproduce it with my current setup several times. You can look at my app's structure here:
https://github.com/anovelmous-dev-squad/anovelmous
When I comment out where default_app_config is set in the app's init.py, all my custom commands can be found again.
https://github.com/anovelmous-dev-squad/anovelmous/blob/master/anovelmous_app/__init__.py
Change History (7)
follow-up: 3 comment:1 by , 9 years ago
comment:2 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 9 years ago
Replying to timgraham:
It looks like you have set AppConfig.name incorrectly. It points to 'api' but the Python path for that app appears to be 'anovelmous_app'.
When I change the name property to "anovelmous_app", I receive a LookupError.
LookupError: App 'anovelmous_app' doesn't have a 'Token' model.
I originally tried this setup to no avail, and it looked incorrect from the start. I need access to a database model on initialization that is defined in the api package. It works as expected when supplying "api" to the name property, except when looking for django commands.
follow-up: 5 comment:4 by , 9 years ago
Okay, but that doesn't look like a bug in Django. Please see TicketClosingReasons/UseSupportChannels for ways to get help.
I will however propose a documentation patch which might help you understand why things aren't working as you expect.
-
docs/ref/applications.txt
diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt index eb3cc6f..d634e73 100644
a b Methods 204 204 205 205 .. method:: AppConfig.get_models() 206 206 207 Returns an iterable of :class:`~django.db.models.Model` classes. 207 Returns an iterable of :class:`~django.db.models.Model` classes for this 208 application. 208 209 209 210 .. method:: AppConfig.get_model(model_name) 210 211 211 212 Returns the :class:`~django.db.models.Model` with the given 212 ``model_name``. Raises :exc:`LookupError` if no such model exists .213 ``model_name`` is case-insensitive.213 ``model_name``. Raises :exc:`LookupError` if no such model exists in this 214 application. ``model_name`` is case-insensitive. 214 215 215 216 .. method:: AppConfig.ready() 216 217
comment:5 by , 9 years ago
Replying to timgraham:
Okay, but that doesn't look like a bug in Django. Please see TicketClosingReasons/UseSupportChannels for ways to get help.
I will however propose a documentation patch which might help you understand why things aren't working as you expect.
docs/ref/applications.txt
diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt index eb3cc6f..d634e73 100644
a b Methods 204 204 205 205 .. method:: AppConfig.get_models() 206 206 207 Returns an iterable of :class:`~django.db.models.Model` classes. 207 Returns an iterable of :class:`~django.db.models.Model` classes for this 208 application. 208 209 209 210 .. method:: AppConfig.get_model(model_name) 210 211 211 212 Returns the :class:`~django.db.models.Model` with the given 212 ``model_name``. Raises :exc:`LookupError` if no such model exists .213 ``model_name`` is case-insensitive.213 ``model_name``. Raises :exc:`LookupError` if no such model exists in this 214 application. ``model_name`` is case-insensitive. 214 215 215 216 .. method:: AppConfig.ready() 216 217
Thank you, I ended up moving the AppConfig over to the other package and listed it in INSTALLED_APPS, resolving my issue. The documentation change does help clarify the issue.
It looks like you have set AppConfig.name incorrectly. It points to 'api' but the Python path for that app appears to be 'anovelmous_app'.