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

AttributeError: ‘str‘ object has no attribute ‘decode‘,第1张

背景

python 3.7.6
django 2.2

现象

执行python manage.py makemigrations时报错:

  File "E:\software\Python3-64bit\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'
原因

原因目前未知,部分版本就会出现这个问题。

解决方式

修改{PYHTON_HOME}\lib\site-packages\django\db\backends\mysql\operations.py的146行,将
query = query.decode(errors=‘replace’)修改为query = query.encode(errors=‘replace’)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/714304.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-24
下一篇 2022-04-24

发表评论

登录后才能评论

评论列表(0条)

保存