[Django]-South migration error: NoMigrations exception for django.contrib.auth

26πŸ‘

βœ…

I solved the problem.

Obviously, you can’t use South to do the migrations for the apps that are part of Django, like β€˜auth’ so I didn’t know why it was trying to.

I realised that for a while I had another app within my project called auth. I must have tried to migrate this at some point before renaming it and therefore messed it all up.

I removed the migration history entries from the database for that app and everything was fine.

πŸ‘€danpalmer

43πŸ‘

Leaving this here for future googlers

I recently ran into this exceptions with one of my own apps today, not a contrib one.

After a bit of head-scratching I noticed that somehow the file …

 app/migrations/__init__.py

… had been deleted, which means python cant import the dir as a module etc etc.

πŸ‘€sjh

11πŸ‘

I just ran into this after swithcing branches and app versions, and decided to remove the app that now had no migrations from the south_migrationhistory table

./manage.py dbshell

mysql> SELECT * FROM south_migrationhistory WHERE app_name = 'social_auth';

104 | social_auth | 0001_initial...                                                                   
105 | social_auth | 0002_auto__add_unique_nonce...


mysql> DELETE FROM south_migrationhistory WHERE app_name = 'social_auth';
Query OK, 2 rows affected (0.00 sec)
πŸ‘€Tom Gruner

5πŸ‘

I also had the same problem, and at the end I fixed this by deleting all rows from south_migrationhistory table and run the following command from terminal.

python manage.py reset south

This answer explain about how to reset south migration history.

Edit:

From Django 1.5 onwards reset command won’t work. Instead you have to use flush.

python manage.py flush

To understand more about what flush will do read this stackoverflow answer.

πŸ‘€Jinesh

1πŸ‘

I also had the same issue, however this happened to the root application. I discovered that this was due to an empty models.py in my project root from earlier development. I suspect this issue may arise for project applications also.

πŸ‘€Dan Ward

1πŸ‘

You can do migrations on built-in modules, and it definitely makes sense for data migrations, for example, truncating all usernames, removing invalid emails, et cetera.

In the case of a User from django.contrib.auth.models, simply use: orm[β€˜auth.User’]

πŸ‘€mrooney

0πŸ‘

I got the same error, but not for a django module, but for a module that was part of my virtualenv. I didn’t get how south could have done a migration for that module, since it really didn’t have any migrations. Then I remembered I had copied the database from an test env that was supposed to be the same. But it turned out the other env had a slightly different version of the module which did have a migration.
I ended up deleting the offending row from the south migrationhistory (since it was a test env anyway).

0πŸ‘

I had a similar problem with django.contrib.admin not letting me run my migrations. I solved it by disabling django.contrib.admin in settings.INSTALLED_APPS

πŸ‘€mpaf

Leave a comment