替换django的user模型出现的异常InconsistentMigrationHistory

AbstractUser 替换user Model,在migrate时报错

...
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'.
...

解决方法:

  1. 注释掉admin app

INSTALLED_APPS = [
    # 'django.contrib.admin',
    ...
]
  1. Migrate
python manage.py migrate
  1. 取消注释
INSTALLED_APPS = [
    'django.contrib.admin',
    ...
]

PS: 百度出来的全是删库重建,看到我心惊胆跳,心中只有一个念头:删库跑路。。。

django.db.migrations.exceptions.InconsistentMigrationHistory

你可能感兴趣的:(替换django的user模型出现的异常InconsistentMigrationHistory)