Django2.0版本以上与pymsql 不匹配问题以及解决方法
Django 2.0 以上 如果使用pymysql0.93,需要一下两步操作:
# 1 第一次报错信息:
File "D:virtualenvwxlibsite-packagesdjangodbackendsmysqlase.py", line 36, in <module>
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
#1.1 根据提示信息进入源码注销这两行,然后在运行
# if version < (1, 3, 13):
# raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
# 2 第二次报错处
File "D:virtualenvluffylibsite-packagesdjangodbackendsmysqloperations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
# 2.2 在根据提示信息进入源码
# 在query = query.decode(errors='replace')解码这行上面,添加一行编码:
# query = query.encode('utf8')