Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25356 closed Bug (fixed)

startapp template mustn't encourage using default_app_config

Reported by: Aymeric Augustin Owned by: Aymeric Augustin
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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)

comment:1 by Tim Graham, 9 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Tim Graham, 9 years ago

Has patch: set

comment:3 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 862de0b:

Fixed #25356 -- Removed default_app_config from startapp template.

Also discouraged its use outside the intended use case.

comment:4 by Aymeric Augustin, 9 years ago

Has patch: unset
Resolution: fixed
Severity: Release blockerNormal
Status: closednew

Thanks Tim. Assigning to myself as a reminder to restructure the text a bit.

comment:5 by Aymeric Augustin, 9 years ago

Owner: changed from Tim Graham to Aymeric Augustin
Status: newassigned

comment:6 by Aymeric Augustin, 9 years ago

Has patch: set

comment:7 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Aymeric Augustin <aymeric.augustin@…>, 9 years ago

In 94a36cfd:

Recommended against default_app_config.

Most likely this is a losing fight -- people seem to love this small
convention -- but at least the reasons for avoiding it will be
documented.

Refs #25356.

comment:9 by Aymeric Augustin <aymeric.augustin@…>, 9 years ago

In 76bf4bc:

[1.8.x] Recommended against default_app_config.

Most likely this is a losing fight -- people seem to love this small
convention -- but at least the reasons for avoiding it will be
documented.

Refs #25356.

Backport of 94a36cf from master

comment:10 by Tim Graham, 9 years ago

Resolution: fixed
Status: assignedclosed

comment:11 by Tim Graham <timograham@…>, 9 years ago

In 6258e163:

Refs #24971, #25356 -- Clarified how apps.py works in 1.9 release notes.

comment:12 by Tim Graham <timograham@…>, 9 years ago

In 7bbfc43e:

[1.9.x] Refs #24971, #25356 -- Clarified how apps.py works in 1.9 release notes.

Backport of 6258e163352690faf20bfc92c12468316d1a47ae from master

Note: See TracTickets for help on using tickets.
Back to Top