流沙团
AttributeError: 'str' object has no attribute 'decode'
2021-4-15 流沙团


0x01 错误原因




python manage.py makemigrations




报错提示: AttributeError: 'str' object has no attribute 'decode'



0x02 解决


直接定位到报错文件

C:\python38\Lib\site-packages\django\db\backends\mysql\operations.py

修改源码:


# 头部导入
from django.utils.encoding import force_text

# 报错的位置更改
query = getattr(cursor, '_executed', None)
# if query is not None:
# query = query.decode(errors='replace')
# return query
return force_text(query, errors='replace')
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容