#32642 closed Bug (invalid)
RuntimeError: 'apps.core.apps' declares more than one default AppConfig on custom admin setup
Reported by: | Ronny Vedrilla | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Julien Chiron | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi!
I just migrated my project to django 3.2 and I get the following error:
RuntimeError: 'apps.core.apps' declares more than one default AppConfig: 'AdminConfig', 'CustomAdminConfig'.
Here is my apps.py:
from django.contrib.admin.apps import AdminConfig class CustomAdminConfig(AdminConfig): default_site = 'apps.core.admin.site.CustomAdminSite'
To narrow down the bug I renamed the import:
from django.contrib.admin.apps import AdminConfig as XAdminConfig class CustomAdminConfig(XAdminConfig): default_site = 'apps.core.admin.site.CustomAdminSite'
Then the error changes to:
RuntimeError: 'apps.core.apps' declares more than one default AppConfig: 'XAdminConfig', 'CustomAdminConfig'.
So I guess the new apps autoloader is following the import statement.
I looked at the docs (https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#overriding-the-default-admin-site) but the described way seems like the stuff I did.
I honestly hope, I'm not making any stupid mistakes here.
Best regards and thx!
Ronny
Change History (4)
follow-up: 2 comment:1 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 4 years ago
Cc: | added |
---|---|
Resolution: | invalid |
Status: | closed → new |
Having encountered the same kind of issue while implemeting site-wide custom AdminSite, I found a workaround to make it work.
It seems the documentation should be updated accordingly.
from django.contrib.admin.apps import AdminConfig class MyAdminConfig(AdminConfig): default_site = 'myproject.admin.MyAdminSite'
This raises an exception:
RuntimeError: 'myproject.apps' declares more than one default AppConfig: 'AdminConfig', 'MyAdminConfig'.
It is solved by importing django.contrib.admin.apps instead of django.contrib.admin.apps.AdminConfig:
from django.contrib.admin import apps class MyAdminConfig(apps.AdminConfig): default_site = 'myproject.admin.MyAdminSite'
Then the exception moves on:
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
This is caused by the settings.py configuration:
INSTALLED_APPS = [ 'myproject.apps.MyAdminConfig', #replaces django.contrib.admin ...
It is solved by removing the 'MyAdminConfig' from the settings:
INSTALLED_APPS = [ 'myproject.apps', #replaces django.contrib.admin ...
comment:3 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The current docs works for me.
comment:4 by , 4 years ago
I was able to reproduce this by using an apps.py
module inside an app instead of the project -- I initially missed the myproject/apps.py
in the docs and assumed it belonged in myapp/apps.py
which generates the declares more than one default AppConfig
RuntimeError
.
As far as I'm aware it's not a bug in Django. First of all you should customize a default admin site inside a main project directory (like described in the documentation) not in an app, secondly
INSTALLED_APPS
must point to the config.