I'm having an issue with Django 1.7 to do with the new App Registry, on a particular deployment. Typically I would blow away the instance and recreate it, however it continues to occur when I have destroyed the instance.
It's always the products app that causes this error, and I have used an app.py file to change the label to sc_products, however it now things that sc_products is already defined as well.
In this particular example I was attempting to migrate the app.
Running migrations:
Applying sc_products.0001_initial...Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 91, in apply_migration
if self.detect_soft_applied(migration):
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 135, in detect_soft_applied
apps = project_state.render()
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 57, in render
self.apps = Apps([AppConfigStub(label) for label in sorted(self.real_apps + list(app_labels))])
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/apps/registry.py", line 56, in __init__
self.populate(installed_apps)
File "/home/savingschampion/.virtualenvs/savings_champion/local/lib/python2.7/site-packages/django/apps/registry.py", line 89, in populate
"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: sc_products
I am already doing the following answer by therefromhere:
How to resolve "django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: foo" in Django 1.7?
I've had the same problem and have just stumbled upon this. After debugging django for a little while, I might have the long awaited answer for you.
This most likely happens because your app ends up being treated as both unmigrated and migrated at the same time (thus producing the same error, even when you change the app label), and this in turns happens because your app has both old-style (south) migrations and new-style (django) migrations.
The best and easiest way to deal with this is to start fresh. Delete all your numbered migrations (e.g. rm migrations/0???_*.py*
) and call manage.py makemigrations
anew, ensuring only django migrations are left and are up-to-date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With