本站消息

站长简介/公众号


站长简介:逗比程序员,理工宅男,前每日优鲜python全栈开发工程师,利用周末时间开发出本站,欢迎关注我的微信公众号:幽默盒子,一个专注于搞笑,分享快乐的公众号

  价值13000svip视频教程,python大神匠心打造,零基础python开发工程师视频教程全套,基础+进阶+项目实战,包含课件和源码

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2020-07(10)

2020-08(50)

Django+SQL server migrate 出现 KeyError: ‘deferrable‘ 错误

发布于2020-08-28 21:39     阅读(1231)     评论(0)     点赞(17)     收藏(4)



(venv) D:\996\Django\MM1_engine>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying auth.0008_alter_user_username_max_length...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 "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\commands\migrate.py", line 243, in handle
    post_migrate_state = executor.migrate(
  File "D:\996\Django\MM1_engine\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:\996\Django\MM1_engine\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:\996\Django\MM1_engine\venv\lib\site-packages\django\db\migrations\executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\migrations\operations\fields.py", line 236, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\backends\base\schema.py", line 571, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type,
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\sql_server\pyodbc\schema.py", line 479, in _alter_field
    self.execute(self._create_unique_sql(model, columns=[old_field.column]))
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\sql_server\pyodbc\schema.py", line 861, in execute
    sql = str(sql)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\backends\ddl_references.py", line 200, in __str__
    return self.template % self.parts
KeyError: 'deferrable'

(venv) D:\996\Django\MM1_engine>
(venv) D:\996\Django\MM1_engine>py manage.py startapp ddd

(venv) D:\996\Django\MM1_engine>python manage.py makemigrations
No changes detected

(venv) D:\996\Django\MM1_engine>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying auth.0008_alter_user_username_max_length...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 "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\core\management\commands\migrate.py", line 243, in handle
    post_migrate_state = executor.migrate(
  File "D:\996\Django\MM1_engine\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:\996\Django\MM1_engine\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:\996\Django\MM1_engine\venv\lib\site-packages\django\db\migrations\executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\migrations\operations\fields.py", line 236, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\backends\base\schema.py", line 571, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type,
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\sql_server\pyodbc\schema.py", line 479, in _alter_field
    self.execute(self._create_unique_sql(model, columns=[old_field.column]))
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\sql_server\pyodbc\schema.py", line 861, in execute
    sql = str(sql)
  File "D:\996\Django\MM1_engine\venv\lib\site-packages\django\db\backends\ddl_references.py", line 200, in __str__
    return self.template % self.parts
KeyError: 'deferrable'

Django+SQL server migrate 出现 KeyError: ‘deferrable’ 错误

今天学session的时候遇到该问题

爬了一圈,最终问题应该在 django-mssql-backend 2.8.1与Django 3.1 未兼容所导致
将使用Django3.0即可解决问题。

在这里插入图片描述

原文链接:https://blog.csdn.net/m0_46227797/article/details/108252810






所属网站分类: 技术文章 > 博客

作者:丸子

链接:https://www.pythonheidong.com/blog/article/497046/1703028ecc7725f44eb6/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

17 0
收藏该文
已收藏

评论内容:(最多支持255个字符)