1. 搭建Django2.2+Python3+MySQL时新建app时报错:
1
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

版本信息:

django 2.2.1

mysqlclient 1.3.14

python 3.7

原因:python3.6 myclient的版本过低,与Django不匹配

解决办法:

找到Python安装路径下的…\Lib\site-packages\django\db\backends\mysql\base.py文件

将文件中的如下代码注释:

1
2
if version < (1, 3, 13):
raise ImproperlyConfigured("mysqlclient 1.3.13 or newer is required; you have %s" % Database.__version__)

重新在项目manage.py路径下执行命令即可。

  1. AttributeError: ‘str’ object has no attribute ‘decode’
1
2
3
4
5
6
7
if query is not None:
query = query.decode(errors='replace')
return query
#改为
if query is not None:
query = query.encode(errors='replace')
return query