Python 引发不一致的迁移历史记录(django.db.migrations.exceptions.unconsistentMigrationHistory:
我运行了Python 引发不一致的迁移历史记录(django.db.migrations.exceptions.unconsistentMigrationHistory:,python,django,database-migration,Python,Django,Database Migration,我运行了python manage.py migrate,出现以下错误: Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\D
python manage.py migrate
,出现以下错误:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\core\management\base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\core\management\commands\migrate.py", line 95, in handle
executor.loader.check_consistent_history(connection)
File "C:\Users\Dell\Desktop\Django\newspaper\venv\lib\site-packages\django\db\migrations\loader.py", line 302, in check_consistent_history
raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'.
运行python manage.py makemigrations用户时,我没有收到任何错误
问题出在哪里?您可以删除所有迁移文件夹/文件,然后重置正在使用的数据库,然后进行迁移。这是否回答了您的问题?
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
age = models.PositiveIntegerField(null=True, blank=True)