1、修改文件site-package/django/db/backends/mysql/base.py
![](https://img.haomeiwen.com/i9101119/48222dbf0f76eb33.png)
注释掉if判断
2、修改文件site-package/django/db/backends/mysql/operations.py
![](https://img.haomeiwen.com/i9101119/be056361dbe37e31.png)
from django.utils.encoding import force_text
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.
query = getattr(cursor, '_executed', None)
if query is not None:
if type(query) == bytes:
query = query.decode(errors='replace')
elif type(query) == str:
query = query.encode(errors='replace')
else:
query = force_text(query, errors='replace')
return query
网友评论