python + django + Mysql中的字符串值不正确 [英] Incorrect string value in python+django+Mysql
本文介绍了python + django + Mysql中的字符串值不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误详细信息:
Warning at /admin/cute/cute/
Incorrect string value: '\xF0\x9F\x98\x89\xE7\x93...' for column 'object_repr' at row 1
Request Method: POST
Request URL: http://api.ourcute.com/admin/cute/cute/?recommend__exact=0
Django Version: 1.7.1
Exception Type: Warning
Exception Value:
Incorrect string value: '\xF0\x9F\x98\x89\xE7\x93...' for column 'object_repr' at row 1
Exception Location: /usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py in _warning_check, line 117
Python Executable: /usr/local/bin/uwsgi
Python Version: 2.7.3
Python Path:
['/opt/cute_project/server/server/',
'/opt/cute_project/server/uwsgi/',
'/opt/cute_project/server/',
'.',
'/opt/cute_project/server',
'/opt/cute_project/server/server/src/django-cache-machine',
'/usr/local/lib/python2.7/dist-packages/oss-0.1.3-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages']
Server time: 星期日, 22 二月 2015 06:34:27 +0800
错误位于由管理模板生成的django管理页面中。
所以我想这应该是mysql设置错误。
The error is located in a django admin page, which is generated by admin template. So I guess it should be mysql setting error.
推荐答案
如果这是一个4字节的闪烁的脸在utf8中,您需要在MySQL中从utf8更改为utf8mb4。
If that is a 4-byte "winking face" in utf8, you need to change from utf8 to utf8mb4 in MySQL.
这篇关于python + django + Mysql中的字符串值不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文