好吧,作为我的愚蠢的一部分,而不是做'冲洗' ,我删除了django项目目录下的sqlite.db文件。 之后,我的db命令都没有工作,例如
python manage.py showmigrations
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "django/lib/python3.4/site- packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "django/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "django/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "django/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "django/lib/python3.4/site-packages/django/core/management/commands/showmigrations.py", line 36, in handle
return self.show_list(connection, options['app_labels'])
File "django/lib/python3.4/site- packages/django/core/management/commands/showmigrations.py", line 44, in show_list
loader = MigrationLoader(connection, ignore_no_migrations=True)
File "django/lib/python3.4/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "django/lib/python3.4/site-packages/django/db/migrations/loader.py", line 176, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "django/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "django/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 56, in ensure_schema
with self.connection.schema_editor() as editor:
File "django/lib/python3.4/site-packages/django/db/backends/sqlite3/schema.py", line 25, in __enter__
self._initial_pragma_fk = c.fetchone()[0]
所有这些命令都因类似原因失败\ b
makemigrations 迁移
答案 0 :(得分:1)
更改django / db / backends / sqlite3 / schema.py的第25行;
self._initial_pragma_fk = c.fetchone()[0]
到这个
self._initial_pragma_fk = 0 # c.fetchone()[0]
可让您继续迁移。
https://code.djangoproject.com/ticket/26205?cversion=0&cnum_hist=2