How to Solve Error Message django.core.exceptions.ImproperlyConfigured: Application labels aren’t unique, duplicates: admin

Posted on

Introduction

This is an article where the content is focusing on how to solve an error message. The focus for solving error message exist in this article. That error message is in the title of this article. In general, the error message exists below :

django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin

Specifically, the error message for the complete one exist below :

(env) C:\programming\python\myproject>python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\programming\python\env\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\programming\python\env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\programming\python\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\programming\python\env\lib\site-packages\django\apps\registry.py", line 93, in populate
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin

Solution

The solution for the above problem is actually quite simple. Basically, the cause may have been the mistake of the coder, programmer or the developer itself. It is because the definition of the ‘admin’ is duplicate. The information about the error is very clear to understand as follows :

Application labels aren't unique, duplicates: admin

Where is the duplication exist ?. Well, after searching further, the duplication actually exist in the ‘settings.py’ file of the configuration project. The duplication itself exist in the part for defining the installed application as in the following part of the configuration :

# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.flatpages',
    'crispy_forms',
]

The definition for the ‘admin’ apps represented by the line ‘django.contrib.admin’ have double declaration. So, in order to solve it, just remark or comment one of the definition. Either in the first line or the following line. In this example, commenting the following line is an attempt to solve it. The configuration will be as in the following part :

# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    # 'django.contrib.admin',
    'django.contrib.flatpages',
    'crispy_forms',
]

After editing the ‘settings.py’ file exist in the root folder of the project, just run the application once more. If there are no further error exist, the application will run normally.

Leave a Reply