A Django project that includes a custom application named admin may fail to start with an error regarding duplicate application labels.
The runtime error appears as follows:
Traceback (most recent call last):
...
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
The error message indicates a conflict: the application label admin has been registered more than once. This often occurs because a custom application's label matches the label used by Django's built-in admin system.
Examine the projcet's INSTALLED_APPS setting in settings.py:
INSTALLED_APPS = [
'django.contrib.admin', # Built-in Django admin app
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'admin.apps.AdminConfig', # Custom application causing conflict
]
Both entries 'django.contrib.admin' and 'admin.apps.AdminConfig' are associated with the application label 'admin', resulting in the duplicate.
If the custom app's configuration admin.apps.AdminConfig is removed or commented out, other errors, such as database connection issues, may become visible, but these are separate from the label conflict. For instance, an error regarding the mysqlclient library might appear:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
Did you install mysqlclient or MySQL-python?
This database error relates to a misssing MySQL adapter package, not the label conflict.
The root cause is the naming collision. Django's internal app registry uses the label attribute from an app's AppConfig class, defined in apps.py. When a custom app is named admin, its configuration class (e.g., AdminConfig) inherently claims the label 'admin', which conflicts with the built-in admin application.
The solution is to rename the custom application directory to a unique name that does not conflict with any built-in Django components. Avoid using reserevd names like admin, auth, or contenttypes. After renaming the application folder, update the INSTALLED_APPS entry to reference the new path, such as 'myadmin.apps.MyAdminConfig', ensuring all imports within the project reflect this change.