[Django] #25381: "default_app_config" causes custom commands to not be found

22 views
Skip to first unread message

Django

unread,
Sep 11, 2015, 1:53:17 AM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
--------------------------------------------+--------------------
Reporter: thebritican | Owner: nobody
Type: Bug | Status: new
Component: Core (Management commands) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------------+--------------------
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]

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

Django

unread,
Sep 11, 2015, 9:54:24 AM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------

Reporter: thebritican | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

It looks like you have set
[https://docs.djangoproject.com/en/stable/ref/applications/#django.apps.AppConfig.name
AppConfig.name] incorrectly. It [https://github.com/anovelmous-dev-
squad/anovelmous/blob/7239e33172eeb411462bfefdff92aa71576f0d48/anovelmous_app/apps.py#L9
points to 'api'] but the Python path for that app appears to be
'anovelmous_app'.

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

Django

unread,
Sep 11, 2015, 12:08:23 PM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------
Reporter: thebritican | Owner: nobody
Type: Bug | Status: closed

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => invalid


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

Django

unread,
Sep 11, 2015, 12:13:31 PM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------
Reporter: thebritican | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by thebritican):

Replying to [comment:1 timgraham]:


> It looks like you have set
[https://docs.djangoproject.com/en/stable/ref/applications/#django.apps.AppConfig.name
AppConfig.name] incorrectly. It [https://github.com/anovelmous-dev-
squad/anovelmous/blob/7239e33172eeb411462bfefdff92aa71576f0d48/anovelmous_app/apps.py#L9
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.

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

Django

unread,
Sep 11, 2015, 12:27:21 PM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------
Reporter: thebritican | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by 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.
{{{#!diff
diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt
index eb3cc6f..d634e73 100644
--- a/docs/ref/applications.txt
+++ b/docs/ref/applications.txt
@@ -204,13 +204,14 @@ Methods

.. method:: AppConfig.get_models()

- Returns an iterable of :class:`~django.db.models.Model` classes.
+ Returns an iterable of :class:`~django.db.models.Model` classes for
this
+ application.

.. method:: AppConfig.get_model(model_name)

Returns the :class:`~django.db.models.Model` with the given
- ``model_name``. Raises :exc:`LookupError` if no such model exists.
- ``model_name`` is case-insensitive.
+ ``model_name``. Raises :exc:`LookupError` if no such model exists in
this
+ application. ``model_name`` is case-insensitive.

.. method:: AppConfig.ready()

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25381#comment:4>

Django

unread,
Sep 11, 2015, 12:48:15 PM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------
Reporter: thebritican | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by thebritican):

Replying to [comment:4 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.
> {{{#!diff
> diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt
> index eb3cc6f..d634e73 100644
> --- a/docs/ref/applications.txt
> +++ b/docs/ref/applications.txt
> @@ -204,13 +204,14 @@ Methods
>
> .. method:: AppConfig.get_models()
>
> - Returns an iterable of :class:`~django.db.models.Model` classes.
> + Returns an iterable of :class:`~django.db.models.Model` classes for
this
> + application.
>
> .. method:: AppConfig.get_model(model_name)
>
> Returns the :class:`~django.db.models.Model` with the given
> - ``model_name``. Raises :exc:`LookupError` if no such model exists.
> - ``model_name`` is case-insensitive.
> + ``model_name``. Raises :exc:`LookupError` if no such model exists
in this
> + application. ``model_name`` is case-insensitive.
>
> .. method:: AppConfig.ready()
>
> }}}

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/25381#comment:5>

Django

unread,
Sep 11, 2015, 2:09:16 PM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------
Reporter: thebritican | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"e7e8d30cae9457339eb49ae8584e82ff0a038e99" e7e8d30]:
{{{
#!CommitTicketReference repository=""
revision="e7e8d30cae9457339eb49ae8584e82ff0a038e99"
Refs #25381 -- Clarified that AppConfig model methods search only the
current app.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25381#comment:6>

Django

unread,
Sep 11, 2015, 2:09:26 PM9/11/15
to django-...@googlegroups.com
#25381: "default_app_config" causes custom commands to not be found
-------------------------------------+-------------------------------------
Reporter: thebritican | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"95c00c40ae62c4e723a3498722ab3a0921aa46e5" 95c00c4]:
{{{
#!CommitTicketReference repository=""
revision="95c00c40ae62c4e723a3498722ab3a0921aa46e5"
[1.8.x] Refs #25381 -- Clarified that AppConfig model methods search only
the current app.

Backport of e7e8d30cae9457339eb49ae8584e82ff0a038e99 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25381#comment:7>

Reply all
Reply to author
Forward
0 new messages