DjangoプロジェクトがAttributeErrorを報告します:migrateの実行後に「str」オブジェクトに属性「decode」がありません

  File "C:\Python\Python36\lib\site-packages\django\db\backends\utils.py", line 103, in execute
    sql = self.db.ops.last_executed_query(self.cursor, sql, params)
  File "C:\Python\Python36\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'

C:\ Python \ Python36 \ lib \ site-packages \ django \ db \ backends \ mysql \ operations.pyをクリックして検索します

        query = getattr(cursor, '_executed', None)
        if query is not None:
            query = query.decode(errors='replace')  # 146行
        return query

行146をに変更します

query = query.encode('utf-8').decode(errors='replace')

おすすめ

転載: blog.csdn.net/qq_31910669/article/details/114545599