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卸了重下)。
相关文章
相关标签/搜索