Invalid string value in python + django + Mysql

Error Details:

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

The error is located on the django administration page, which is created by the admin template. Therefore, I assume that this should be a mysql installation error.

0
source share
1 answer

If this is a 4-byte winking face in utf8, you need to switch from utf8 to utf8mb4 in MySQL.

0
source

Source: https://habr.com/ru/post/1619858/


All Articles