Environment:
Ubuntu18.04
MySQL: 8.0
Python: 3.6.8
Django: 2.2.6
pymysql: 0.9.3
Installation pymysql
pip install pymysql
The pymysql introduced into django
The following code is written in the name of the package below __init__.py files and projects in the same directory:
import pymysql pymysql.install_as_MySQLdb()
Django configuration in mysql, then start django service, we found being given as follows:
File "/home/www/.local/share/virtualenvs/EduScore-UXZMOCwv/lib/python3.6/site-packages/django/db/backends/mysql/base.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.
Solution:
Use vim to open the/home/www/.local/share/virtualenvs/EduScore-UXZMOCwv/lib/python3.6/site-packages/django/db/backends/mysql/base.py
file, comment out the following code#if version < (1, 3, 13): # raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
Start django server found or an error, the error message is:
AttributeError: 'str' object has no attribute 'decode'
Solution:
Find the corresponding file, an error will decode line can be changed to encode.