解决:Django中AttributeError:'str'objects has no attribute 'decode' 一:问题 二:解决步骤

本文内容皆为作者原创,如需转载,请注明出处:https://www.cnblogs.com/xuexianqi/p/13230935.html

在搭建完django项目,执行数据迁移命令python3 manage.py makemigrations,遇到了这样的报错:

解决:Django中AttributeError:'str'objects has no attribute 'decode'
一:问题
二:解决步骤

根据报错提示,是因为str对象没有decode属性

二:解决步骤

1.打开pycharm命令行的报错信息,找到最后一条的提示,打开以下路径中operations.py,找到146行

libsite-packagesdjangodbackendsmysqloperations.py

解决:Django中AttributeError:'str'objects has no attribute 'decode'
一:问题
二:解决步骤

2.然后注释掉,会有弹框(因为修改的是源代码),直接点击OK即可

解决:Django中AttributeError:'str'objects has no attribute 'decode'
一:问题
二:解决步骤

3.再次执行命令,OK!

解决:Django中AttributeError:'str'objects has no attribute 'decode'
一:问题
二:解决步骤