django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applie

 

Problem

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

So we can migrate database without admin(admin.0001_initial) firstly.

After its dependency migrated, execute commands to migrate admin.0001_initial.

Solution

  1. remove 'django.contrib.admin' from INSTALLED_APPS in settings.py.
  2. execute commands:

Python manage.py makemigrations appname

Python manage.py migrate appname

  1. add 'django.contrib.admin' to INSTALLED_APPS in settings.py file.
  2. execute commands again:

$: Python manage.py makemigrations appname

$: Python manage.py migrate appname

For me removing 'django.contrib.admin' from INSTALLED_APPS and running makemigrations results in LookupError: No installed app with label 'admin'. 

    go to urls.py and comment out urls with admin 

参与评论 您还未登录,请先 登录 后发表或查看评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值