Django2.0同步Mysql數據庫時出現的問題
執行 python manage.py makemigrations 報錯
# 報錯位置 File "G:\python\lib\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
解決方案
第一步:
點擊報錯位置找到這兩行 注釋掉
version = Database.version_info # if version < (1, 3, 13): # raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
第二步
再次執行python manage.py makemigrations 報錯
# 報錯路徑
File "G:\python\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query query = query.decode(errors='replace')
# 報錯問題 AttributeError: 'str' object has no attribute 'decode'
修改 :將代碼里面query.decode改成:query.encode
if query is not None: query = query.encode(errors='replace') # 修改后的 return query