close

[Solved] django.db.migrations.exceptions.InconsistentMigrationHistory

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error django.db.migrations.exceptions.InconsistentMigrationHistory in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How django.db.migrations.exceptions.InconsistentMigrationHistory Error Occurs?

Today I get the following error django.db.migrations.exceptions.InconsistentMigrationHistory in python.

How To Solve django.db.migrations.exceptions.InconsistentMigrationHistory Error ?

  1. How To Solve django.db.migrations.exceptions.InconsistentMigrationHistory Error ?

    To Solve django.db.migrations.exceptions.InconsistentMigrationHistory Error Your django_migrations table in your database is the cause of inconsistency and deleting all the migrations just from local path won't work.

  2. django.db.migrations.exceptions.InconsistentMigrationHistory

    To Solve django.db.migrations.exceptions.InconsistentMigrationHistory Error Your django_migrations table in your database is the cause of inconsistency and deleting all the migrations just from local path won't work.

Solution 1

Your django_migrations table in your database is the cause of inconsistency and deleting all the migrations just from local path won’t work.

You have to truncate the django_migrations table from your database and then try applying the migrations again. It should work but if it does not then run makemigrations again and then migrate.

Note: don’t forget to take a backup of your data.

Solution 2

Since you are using a custom User model, you can first comment out

INSTALLED_APPS = [
...
#'django.contrib.admin',
...
]

in your Installed_Apps settings. Then run

python manage.py migrate.

When done uncomment

'django.contrib.admin'

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read