Django项目在把Git上项目拉到本地后,运行完 python manage.py makemigrations后,再运行python manage.py migrate,出现报错:
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency authentication.0001_initial on database 'default'.解决办法:
- 删除数据库中名为django_migrations表
- 删除app下migrations下生成的001_initial.py等文件,只保留__init__.py文件
- 重新运行python manage.py makemigrations后,再运行python manage.py migrate
django.db.utils.OperationalError: (1050, "Table 'django_content_type' already exists")解决办法:
- 删除数据库中名为django_migrations表
- 删除app下migrations下生成的001_initial.py等文件,只保留__init__.py文件
- 重新运行python manage.py makemigrations
- 运行python manage.py migrate --fake