Opened 5 years ago
Last modified 5 years ago
#32692 closed Bug
Django 3.2 automatic AppConfig discovery breaks projects working in 3.1.8 — at Initial Version
| Reported by: | Manel Clos | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 3.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The described method of overriding the default admin site (https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#overriding-the-default-admin-site), is not compatible with automatic AppConfig discovery, if the app (myproject, or myapps) is already in INSTALLED_APPS.
How to reproduce
pip install Django==3.2django-admin startproject myprojectpython manage.py migratepython manage.py createsuperuser- Put a template in
myproject/templates/admin/base_site.html - Add
myprojecttoINSTALLED_APPS python manage.py runserverworks, I can access the admin site and see the changes in templates- Follow the guide to override the default admin site, https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#overriding-the-default-admin-site, this is, create
myproject/admin.py,myproject/apps.pyand modifysettings.py. python manage.py runserver
Actual result
RuntimeError: 'myproject.apps' declares more than one default AppConfig: 'AdminConfig', 'MyAdminConfig'.`
This a regression
pip install Django==3.1.8python manage.py runserver- All ok, both templates and AdminConfig working at the same time
Workaroud
- use
app-admin.pyinstead ofapps.pywhen following the documentation to override the default admin site - adjust settings.py:
'myproject.apps-admin.MyAdminConfig'in INSTALLED_APPS - works with Django 3.2
Note:
See TracTickets
for help on using tickets.