报错为SQL error
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"
此问题是django 2.0以上对mysql 的datetime数据类型增加了精度为6,要求mysql版本必须为5.5以上。而现有数据库mysql低于5.5,
- 解决办法
- 更换5.5以上的mysql
- 在settings.py 新增以下行
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime' # fix for MySQL 5.5
网友评论