File "/usr/local/python3/lib/python3.6/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'
注销
if query is not None:
query = query.decode(errors=‘replace’)
def last_executed_query(self, cursor, sql, params):
# With MySQLdb, cursor objects have an (undocumented) "_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
# todo
query = getattr(cursor, '_executed', None)
# if query is not None:
# query = query.decode(errors='replace')
return query
# return force_text(getattr(cursor, '_executed', None), errors='replace')
import pymysql
pymysql.version_info = (1, 3, 13, "final", 0) # 解决mysql版本问题报错而添加的代码
pymysql.install_as_MySQLdb()