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.
* 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>
* status: new => closed
* resolution: => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/25381#comment:2>
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>
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>
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>
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>
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>