在新的MSSQL服务器上运行迁移时,出现以下错误 应用帐户.0001\u初始…回溯(最近一次呼叫最后一次): 文件“manage.py”,第22行,在 main() 文件“manage.py”,第18行,主 从命令行(sys.argv)执行命令 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/\uuuu init\uuuuuuuuuu.py”,第419行,从命令行执行 utility.execute() 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/_init__.py”,第413行,在execute中 self.fetch_命令(子命令)。从_argv(self.argv)运行_ 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py”,第354行,运行于 self.execute(*args,**cmd_选项) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py”,第398行,在execute中 输出=self.handle(*args,**选项) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py”,第89行,包装 res=句柄函数(*args,**kwargs) handle中的文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/commands/migrate.py”,第244行 post\u migrate\u state=executor.migrate( 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex ecutor.py”,migrate中的第117行 状态=自我。\迁移\全部\向前(状态、计划、完整计划、假=假、假初始=假初始) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex ecutor.py”,第147行,全部向前迁移 state=self.apply\u迁移(state,migration,fake=fake,fake\u initial=fake\u initial) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex ecutor.py”,第230行,在apply_migration中 迁移记录=真 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/base/schema.py”,第118行,在退出时__ self.execute(sql) 文件“/usr/local/lib/python3.8/dist-packages/sql_-server/pyodbc/schema.py”,lin e 871,在execute中 sql=str(sql) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/ddl uu.references.py”,第201行,在__ 返回self.template%self.parts KeyError:“包括”

在新的MSSQL服务器上运行迁移时,出现以下错误 应用帐户.0001\u初始…回溯(最近一次呼叫最后一次): 文件“manage.py”,第22行,在 main() 文件“manage.py”,第18行,主 从命令行(sys.argv)执行命令 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/\uuuu init\uuuuuuuuuu.py”,第419行,从命令行执行 utility.execute() 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/_init__.py”,第413行,在execute中 self.fetch_命令(子命令)。从_argv(self.argv)运行_ 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py”,第354行,运行于 self.execute(*args,**cmd_选项) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py”,第398行,在execute中 输出=self.handle(*args,**选项) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py”,第89行,包装 res=句柄函数(*args,**kwargs) handle中的文件“/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/commands/migrate.py”,第244行 post\u migrate\u state=executor.migrate( 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex ecutor.py”,migrate中的第117行 状态=自我。\迁移\全部\向前(状态、计划、完整计划、假=假、假初始=假初始) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex ecutor.py”,第147行,全部向前迁移 state=self.apply\u迁移(state,migration,fake=fake,fake\u initial=fake\u initial) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex ecutor.py”,第230行,在apply_migration中 迁移记录=真 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/base/schema.py”,第118行,在退出时__ self.execute(sql) 文件“/usr/local/lib/python3.8/dist-packages/sql_-server/pyodbc/schema.py”,lin e 871,在execute中 sql=str(sql) 文件“/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/ddl uu.references.py”,第201行,在__ 返回self.template%self.parts KeyError:“包括”,python,django,django-models,django-migrations,Python,Django,Django Models,Django Migrations,此代码与我的网站中处理在线用户的部分有问题,我不知道到底是什么导致了问题,但如果我再次尝试运行迁移,它会显示已存在一个名为db的帐户用户。如果您需要任何其他信息,请询问 编辑1 Applying account.0001_initial...Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py&q

此代码与我的网站中处理在线用户的部分有问题,我不知道到底是什么导致了问题,但如果我再次尝试运行迁移,它会显示已存在一个名为db的帐户用户。如果您需要任何其他信息,请询问

编辑1

  Applying account.0001_initial...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 "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             __init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             __init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex                                                                                                             ecutor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_i                                                                                                             nitial=fake_initial)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex                                                                                                             ecutor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_                                                                                                             initial)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex                                                                                                             ecutor.py", line 230, in apply_migration
    migration_recorded = True
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/base                                                                                                             /schema.py", line 118, in __exit__
    self.execute(sql)
  File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/schema.py", lin                                                                                                             e 871, in execute
    sql = str(sql)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/ddl_                                                                                                             references.py", line 201, in __str__
    return self.template % self.parts
KeyError: 'include'
来自django.contrib导入管理
从django.url导入包括,路径
从account.views导入(
注册,
注销视图,
登录视图,
#帐户\u编辑\u视图,
帐户(u)视图,,
账户(创建)酒吧(零订单),,
打印条形码零订单视图,
选择订单类型,
)
从framework.views导入(
指数
)
URL模式=[
路径(“”,索引,name='home'),
路径('register/',registation,name=“register”),
路径('logout/',logout_视图,name=“logout”),
路径('login/',login_视图,name=“login”),
#路径('account/edit/',account\u edit\u视图,name=“account\u edit”),
路径('account/',account_视图,name=“account”),
路径('admin/',admin.site.url),
路径('account/AddOrder/BarZero',account\u create\u BarZero\u order,name=“create\u BarZero\u order”),
路径('account/order/',print\u barzero\u order\u view,name=“print\u barzero\u order”),
路径(“账户/订单/选择”,选择订单类型,name=“选择订单类型”)
]
编辑2

在从URL.py中删除include后,由于意识到它没有在任何地方使用,我重新运行迁移,并出现此错误

from django.contrib import admin
from django.urls import include, path

from account.views import (
    registration,
    logout_view,
    login_view,
#    account_edit_view,
    account_view,
    account_create_barzero_order,
    print_barzero_order_view,
    choose_order_type,
)
from framework.views import(
    index
)

urlpatterns = [
    path('', index, name='home'),
    path('register/', registration, name="register"),
    path('logout/', logout_view, name="logout"),
    path('login/', login_view, name="login"),
#    path('account/edit/', account_edit_view, name="account_edit"),
    path('account/',account_view, name="account"),
    path('admin/', admin.site.urls),
    path('account/AddOrder/BarZero', account_create_barzero_order, name="create_barzero_order"),
    path('account/order/<int:order_id>', print_barzero_order_view, name="print_barzero_order"),
    path('account/order/choose', choose_order_type , name="choose_order_type")
]
文件“/home/cagenix/.local/lib/python3.8/site packages/django/db/backends/utils.py”,第84行,在
返回self.cursor.execute(sql,params)
文件“/usr/local/lib/python3.8/dist packages/sql\u server/pyodbc/base.py”,第555行,在execute中
返回self.cursor.execute(sql,params)
pyodbc.ProgrammingError:('42000',“[42000][Microsoft][ODBC Driver 17 for SQL Server][SQL Server]列'Prosthodontist.Customer Number'与外键'account\u user\u Prosthodontist\u id\u 8fda3091\u fk\u Prosthodontist\u Customer Number'中引用列'account\u user.Prosthodontist\u id'的数据类型不同。(1778)(SQLExecDirectW)]
上述异常是以下异常的直接原因:
回溯(最近一次呼叫最后一次):
文件“manage.py”,第22行,在
main()
文件“manage.py”,第18行,在
File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
  return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/base.py", line 555, in execute
  return self.cursor.execute(sql, params)
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Column 'Prosthodontist.Customer Number' is not the same data type as referencing column 'account_user.prosthodontist_id' in foreign key 'account_user_prosthodontist_id_8fda3091_fk_Prosthodontist_Customer Number'. (1778) (SQLExecDirectW)")

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

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 "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/home/cagenix/.local/lib/python3.8/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 "/home/cagenix/.local/lib/python3.8/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 "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/executor.py", line 230, in apply_migration
    migration_recorded = True
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 118, in __exit__
    self.execute(sql)
  File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/schema.py", line 882, in execute
    cursor.execute(sql, params)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/base.py", line 555, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Column 'Prosthodontist.Customer Number' is not the same data type as referencing column 'account_user.prosthodontist_id' in foreign key 'account_user_prosthodontist_id_8fda3091_fk_Prosthodontist_Customer Number'. (1778) (SQLExecDirectW)")