加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

django2.0+连接mysql数据库迁移时候报错

发布时间:2020-12-15 17:10:36 所属栏目:大数据 来源:网络整理
导读:django2.0+连接mysql数据库迁移时候报错 情况一 错误信息 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 解决办法 去到 pythonlibsite-packagesdjangodbbackendsmysqlbase.py" 把里面的

django2.0+连接mysql数据库迁移时候报错

情况一

错误信息

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

解决办法

去到pythonlibsite-packagesdjangodbbackendsmysqlbase.py"

把里面的注释掉

# 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'

解决办法

去到pythonlibsite-packagesdjangodbbackendsmysqloperations.py

再原基础上加上query = query.encode('utf8')

改了后效果

        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卸了重下)。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读