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
--
Ticket URL: <https://code.djangoproject.com/ticket/32642>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
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
[https://docs.djangoproject.com/en/3.2/ref/applications/#troubleshooting
the config].
--
Ticket URL: <https://code.djangoproject.com/ticket/32642#comment:1>
* cc: Julien Chiron (added)
* status: closed => new
* resolution: invalid =>
Comment:
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
...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32642#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
The current docs works for me.
--
Ticket URL: <https://code.djangoproject.com/ticket/32642#comment:3>
Comment (by Simon Meers):
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`.
--
Ticket URL: <https://code.djangoproject.com/ticket/32642#comment:4>