执行:python manage.py migrate报错

来源:3-3 创建博客文章模型

慕盖茨3205560

2020-04-10 18:04

(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回答

  • 我是没有昵称
    2021-02-19 12:29:53

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

三小时带你入门Django框架 新版上架

Python开发上手Web框架的必备课程,三小时带你入门Django框架。

25587 学习 · 248 问题

查看课程

相似问题