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

Posted vmsysjack

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django-AttributeError: 'str' object has no attribute 'decode'相关的知识,希望对你有一定的参考价值。


一、Django数据同步过程中遇到的问题:
以下2步骤都需要修改:
  

1、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.

  解决办法:C:Python37Libsite-packagesdjangodbackendsmysql(python安装目录)打开base.py,注释掉以下内容:

        if version < (1, 3, 13):

          raise ImproperlyConfigured(mysqlclient 1.3.13 or newer is required; you have %s. % Database.__version__)

  

2、File "C:Python37libsite-packagesdjangodbackendsmysqloperations.py", line 146, in last_executed_query

    query = query.decode(errors=replace)

  AttributeError: str object has no attribute decode

  解决办法:打开此文件把146行的decode修改为encode

 

以上是关于django-AttributeError: 'str' object has no attribute 'decode'的主要内容,如果未能解决你的问题,请参考以下文章

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

django - AttributeError:'AnonymousUser'对象没有属性'todo'

django - AttributeError:类型对象'file'没有属性'set_user'

Django - 属性错误