为了账号安全,请及时绑定邮箱和手机立即绑定

执行:python manage.py migrate报错

(venv) D:\DjangoProject\django_introduction>python manage.py migrate

Operations to perform:

  Apply all migrations: admin, auth, blog, contenttypes, sessions

Running migrations:

  Applying auth.0010_alter_group_name_max_length...Traceback (most recent call last):

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\backends\utils.py", li

ne 84, in _execute

    return self.cursor.execute(sql)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\backends\sqlite3\base.

py", line 394, in execute

    return Database.Cursor.execute(self, query)

sqlite3.OperationalError: no such table: auth_permission__old


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "manage.py", line 15, in <module>

    execute_from_command_line(sys.argv)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\core\management\__init__.

py", line 401, in execute_from_command_line

    utility.execute()

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\core\management\__init__.

py", line 395, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\core\management\base.py",

 line 328, in run_from_argv

    self.execute(*args, **cmd_options)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\core\management\base.py",

 line 369, in execute

    output = self.handle(*args, **options)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\core\management\base.py",

 line 83, in wrapped

    res = handle_func(*args, **kwargs)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\core\management\commands\

migrate.py", line 233, in handle

    fake_initial=fake_initial,

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\migrations\executor.py

", line 117, in migrate

    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)


  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\migrations\executor.py

", line 147, in _migrate_all_forwards

    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\migrations\executor.py

", line 247, in apply_migration

    migration_recorded = True

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\backends\sqlite3\schem

a.py", line 35, in __exit__

    self.connection.check_constraints()

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\backends\sqlite3\base.

py", line 354, in check_constraints

    column_name, referenced_column_name,

  File "D:\DjangoProject\django_introduction\venv\lib\site-packages\django\db\backends\utils.py", li

(venv) D:\DjangoProject\django_introduction>


这是怎么回事?有人直到怎么回事吗?谢谢

正在回答

1 回答

试一下把数据库删了,重新makemigrations,然后再migrate;不行的话还可以把migrations目录下面的文件清除,然后再执行迁移命令。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

执行:python manage.py migrate报错

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信