startapp template mustn't encourage using default_app_config
I just noticed that startapp
now generates an apps.py
. This isn't unreasonable. However it also sets default_app_config
in __init__.py
. I have strong doubts about this.
default_app_config
is an ugly API that I included reluctantly for one targeted use-case: allowing pre-existing pluggable apps to take advantage of app config functionality in a backwards-compatible fashion, that is, without requiring projets to upgrade their INSTALLED_APPS
settings. The first use of this feature was in django.contrib.admin
in order to get rid of admin.autodiscover()
in urls.py
.
Relying implicitly on a default app config if one exists is clearly a bad practice. The good practice is to specifiy explicitly the full path to the AppConfig
class in INSTALLED_APPS
.
I recommend to:
- remove this line from
app_template/__init__.py
- promote explicit configuration of app configs in
INSTALLED_APPS
- clarify the docs of
default_app_config
with the information I described above
Change History (12)
Owner: |
changed from nobody to Tim Graham
|
Status: |
new →
assigned
|
Triage Stage: |
Unreviewed →
Accepted
|
Resolution: |
→ fixed
|
Status: |
assigned →
closed
|
Has patch: |
unset
|
Resolution: |
fixed
|
Severity: |
Release blocker →
Normal
|
Status: |
closed →
new
|
Owner: |
changed from Tim Graham to Aymeric Augustin
|
Status: |
new →
assigned
|
Triage Stage: |
Accepted →
Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned →
closed
|
PR