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

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

原文链接: AttributeError: 'str' object has no attribute 'decode' 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-649.html )

发表评论

0则评论给“AttributeError: 'str' object has no attribute 'decode'”