django2.0+鏈接mysql數據庫遷移時候報錯

django2.0+鏈接mysql數據庫遷移時候報錯

狀況一

錯誤信息

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解決辦法

去到\python\lib\site-packages\django\db\backends\mysql\base.py"python

把裏面的註釋掉mysql

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

狀況二

錯誤信息

AttributeError: 'str' object has no attribute 'decode'

解決辦法

去到python\lib\site-packages\django\db\backends\mysql\operations.pysql

再原基礎上加上query = query.encode('utf8')數據庫

改了後效果django

if query is not None:
            query = query.encode('utf8')
            query = query.decode(errors='replace')
        return query

狀況三

錯誤信息

ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'api.userinfo', but app 'api' isn't installed.

解決辦法

找到本身的python3.x,進入site-packages/django/contrib/admin/migrations文件目錄下,除了__init__.py文件,其餘的所有刪除。(注意,切勿把__init__.py文件刪了,也不要把contrib/contenttypes這個文件夾下的migrations刪了,否則會致使migrate功能失效,就只能把django卸了重下)。
相關文章
相關標籤/搜索