[Django] #32642: RuntimeError: 'apps.core.apps' declares more than one default AppConfig on custom admin setup

32 views
Skip to first unread message

Django

unread,
Apr 13, 2021, 6:02:51 AM4/13/21
to django-...@googlegroups.com
#32642: RuntimeError: 'apps.core.apps' declares more than one default AppConfig on
custom admin setup
-----------------------------------------+------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/32642>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 13, 2021, 6:40:25 AM4/13/21
to django-...@googlegroups.com
#32642: RuntimeError: 'apps.core.apps' declares more than one default AppConfig on
custom admin setup
-------------------------------+--------------------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* 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>

Django

unread,
Jun 2, 2021, 6:10:13 AM6/2/21
to django-...@googlegroups.com
#32642: RuntimeError: 'apps.core.apps' declares more than one default AppConfig on
custom admin setup
-------------------------------+--------------------------------------

Reporter: Ron | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Julien Chiron):

* 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>

Django

unread,
Jun 2, 2021, 6:34:26 AM6/2/21
to django-...@googlegroups.com
#32642: RuntimeError: 'apps.core.apps' declares more than one default AppConfig on
custom admin setup
-------------------------------+--------------------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

The current docs works for me.

--
Ticket URL: <https://code.djangoproject.com/ticket/32642#comment:3>

Django

unread,
Jun 3, 2021, 7:55:58 AM6/3/21
to django-...@googlegroups.com
#32642: RuntimeError: 'apps.core.apps' declares more than one default AppConfig on
custom admin setup
-------------------------------+--------------------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages