When I run python manage.py migrate
on my Django project, I get the following error:
Traceback (most recent call last):
File \"manage.py\", line
Before performing any other steps, back up your database. Then back it up again.
Remove any custom user model code out of the way, disable your custom model and app in settings, then:
python manage.py dumpdata auth --natural-primary --natural-foreign > auth.json
python manage.py migrate auth zero # This will also revert out the admin migrations
Then add in your custom model, set it in settings, and re-enable the app. Make sure you have no migrations on this app yet.
Then:
python manage.py makemigrations
python manage.py migrate
python manage.py loaddata auth.json # Assumes your user-model isn't TOO dissimilar to the standard one.
Done!