在django连接数据库,执行数据库迁移时候报错django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, “You have an error in your SQL syntax; check the m
anual that corresponds to your MySQL server version for the right syntax to use near ‘(6) NOT NULL)’ at line 1”))
原因是数据库版本与django版本不兼容,意味着我们前期的工作就白做了?可能面临这重新安装MySQL或者django降级升级。但是如果在项目里的话可能会影响到其他代码块,不推荐使用。
其实还有解决办法,既然是兼容性问题,那么让他兼容就行了
办法
在项目settings.py里面加入解决
#设置兼容
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime'