The application then relies on `default_app_config` for locating its
`AppConfig` class (e.g. `"django.contrib.admin.apps.AdminConfig"`).
`default_app_config` was intended to allow author of pluggable
applications to take advantage of `AppConfig` features without require
their users to change `INSTALLED_APPS`, in order to increase adoption.
Unfortunately, that reduced the incentive for directly putting paths to
`AppConfig` in `INSTALLED_APPS`. Even though that was the official
recommendation, it didn't gain traction.
If I had better anticipated this result, I wouldn't have introduced
`default_app_config` in the app-loading refactor in Django 1.7.
We've spent about five years failing at getting people to adopt explicit
configuration. It's time to admit failure. Practicality beats purity.
With the benefit of hindsight, I'm proposing to load `AppConfig` classes
from a conventional location, namely the `apps` submodule inside an
application.
This is inconsistent with Django's design philosophy, as Django favors
configuration over convention, but not much worse than the
`default_app_config` convention.
There's a small risk of backwards-incompatibility. Django could import an
`apps.py` submodule designed for another purpose and that could have side
effects. I think that risk is low.
--
Ticket URL: <https://code.djangoproject.com/ticket/31180>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* component: Core (Serialization) => Core (Other)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:1>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:2>
* owner: nobody => Sanskar Jaiswal
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:3>
* owner: Sanskar Jaiswal => Aymeric Augustin
Comment:
Sanskar, this ticket has a patch already.
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:4>
* stage: Accepted => Ready for checkin
Comment:
Needs a final squash, but looks good.
Pushed some edits so will just give Aymeric a chance to comment again.
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:5>
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
Comment:
This isn't quite ready.
There's a test failure from the new check, for a test added in
dd1ca50b096bf0351819aabc862e91a9797ddaca (after the PR here was first
created):
{{{
======================================================================
ERROR: test_translation_loading (i18n.tests.TranslationLoadingTests)
"loading_app" does not have translations for all languages provided by
----------------------------------------------------------------------
Traceback (most recent call last):
...
File "django/django/apps/registry.py", line 354, in set_installed_apps
self.populate(installed)
File "django/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "django/django/apps/config.py", line 235, in create
app_name, app_config_class.__module__, app_config_class.__name__,
django.core.exceptions.ImproperlyConfigured: Cannot import 'loading_app'.
Check that 'i18n.loading_app.apps.LoadingAppConfig.name' is correct.
}}}
I suspect that's just an artifact of the test case.
Plus, there are a couple of new review comments to double-check.
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:6>
* needs_better_patch: 1 => 0
Comment:
I believe all feedback was addressed and the PR just needs squashing and
merging.
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3f2821af6bc48fa8e7970c1ce27bc54c3172545e" 3f2821af]:
{{{
#!CommitTicketReference repository=""
revision="3f2821af6bc48fa8e7970c1ce27bc54c3172545e"
Fixed #31180 -- Configured applications automatically.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:9>
Comment (by GitHub <noreply@…>):
In [changeset:"287e36bd227a694ba008c28fda1904fbe92df123" 287e36b]:
{{{
#!CommitTicketReference repository=""
revision="287e36bd227a694ba008c28fda1904fbe92df123"
Refs #31180 -- Fixed unreachable assertions in apps tests.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"75d6c4ae6df93c4c4d8621aced3a180afa18a6cb" 75d6c4ae]:
{{{
#!CommitTicketReference repository=""
revision="75d6c4ae6df93c4c4d8621aced3a180afa18a6cb"
Refs #31180 -- Removed default_app_config application configuration
variable per deprecation timeline.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31180#comment:11>