raise MigrationSchemaMissing(“Unable to create the django_migrations table (%s)“ % exc)django.d.....

在使用Django迁移数据时出现报错:

raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))

网上有人说是Django3和MySQL5.5版本不兼容,以下是我的版本号:

但是升级MySQL或降级Django非常麻烦

解决方法:

 在setting配置里加入如下代码:

from django.db.backends.mysql.base import DatabaseWrapper

DatabaseWrapper.data_types['DateTimeField'] = "DateTime"

稀里糊涂就好了,我也不知道为什么...

老师当时加上这段代码就好了,你们也试一试...

猜你喜欢

转载自blog.csdn.net/weixin_47486326/article/details/123043066