搭建Django2.0+Python3+MySQL5時同步數(shù)據(jù)庫時報錯:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None
解決辦法:
找到Python安裝路勁下的Python36-32\Lib\site-packages\django\db\backends\mysql\base.py文件
將文件中的如下代碼注釋
if version < (1, 3, 3):
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
重新在項目manage.py路勁下執(zhí)行如下命令即可
python manage.py makemigrations
python manage.py migrate
附:Django配置MySQL數(shù)據(jù)庫方法
一、settings.py文件中修改數(shù)據(jù)庫配置為下面的內(nèi)容:
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'PORT': '3306',
'NAME': 'mysql',
'USER': 'root',
'PASSWORD': 'zwg123456',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
},
}
}