Django: Application labels aren’t unique

I was updating a site from Django 1.5.x to 1.7 to take advantage of the new, built-in migrations, when I ran into this error:

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

It kind of made sense because I have a directory of common code that has a bunch of apps. I combine that code with my current project by symbolically linking to common_code in my site packages. Both my current project and common_code have apps called “utils”.

In settings.py I load both:

INSTALLED_APPS = [..., 'utils', 'common_code.utils', ...]

Prior to Django 1.7, that worked fine. But that no longer works in 1.7.

The solution is in the new Applications section of the docs. Applying it to my specific case, in my current project utils app, I added a file: apps.py. Here is the contents of apps.py:

from django.apps import AppConfig

class MYUtils(AppConfig):
    name = 'utils' # Full Python path to the application
    label ='my_utils'

The docs mention something about adding code to utils.__init__ to avoid having to change your settings file. But in my case, it seemed simpler to change settings.py to:

INSTALLED_APPS = [..., 'utils.apps.MYUtils', 'common_code.utils', ...]

 

Advertisements

4 thoughts on “Django: Application labels aren’t unique

  1. Hey , I did same as you explained .. getting now Import Error –

    I thought path is not correct — but checked it twice for it and it is correct path only …

    What should I do to resolve this problem

  2. I’m building project with django-oscar. I have to modify the customer view by extending it.
    When I do so then I get this error..”django.core.exceptions.ImproperlyConfigured: Application labels aren’t unique, duplicates: customer”.
    Can you help to solve this?
    Thanks

    • Sorry, I do not have time to dive into this. All I can say is the blog post is directly related to your problem. In my case the app that was a duplicate was utils. In your case its customer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s