请,需要帮助;我使用django 3.1的最后一个版本,使用django-mssql后端迁移ms-sql数据库,当我尝试迁移时,我遇到了这个问题:auth.0008_alter_user_username_max_length。。。追溯(最近一次通话(;
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
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 "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangocoremanagement__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangocoremanagement__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangocoremanagementbase.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangocoremanagementbase.py", line 371, in execute
output = self.handle(*args, **options)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangocoremanagementbase.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangocoremanagementcommandsmigrate.py", line 245, in handle
fake_initial=fake_initial,
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbmigrationsexecutor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbmigrationsexecutor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbmigrationsexecutor.py", line 227, in apply_migration
state = migration.apply(state, schema_editor)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbmigrationsmigration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbmigrationsoperationsfields.py", line 236, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbbackendsbaseschema.py", line 572, in alter_field
old_db_params, new_db_params, strict)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagessql_serverpyodbcschema.py", line 479, in _alter_field
self.execute(self._create_unique_sql(model, columns=[old_field.column]))
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagessql_serverpyodbcschema.py", line 861, in execute
sql = str(sql)
File "C:UsersLeoPycharmProjectsDjangountitledvenvlibsite-packagesdjangodbbackendsddl_references.py", line 200, in __str__
return self.template % self.parts
KeyError: 'deferrable'
我知道这不是解决方案。但我早些时候也遇到过类似的问题。为了解决这个问题,我回滚到Django 3.0.x,然后运行迁移。
希望这也能帮助你:(