The following error was found when adding Chinese characters on the django admin interface:
Warning at /admin/flatpages/flatpage/add/Incorrect string value: '\xE5\x93\x88\xE5\x93\x88...' for column 'content' at row 1Request Method:POSTRequest URL:http://127.0.0.1:8000/admin/flatpages/flatpage/add/Django Version:1.2.1Exception Type:WarningException Value:Incorrect string value: '\xE5\x93\x88\xE5\x93\x88...' for column 'content' at row 1Exception Location:/usr/lib/pymodules/python2.6/MySQLdb/cursors.py in _warning_check, line 82Python Executable:/usr/bin/pythonPython Version:2.6.6
There is no problem with adding English letters before. Check the mysql database encoding and find it is
Latin1_swedish_ci. Previously, phpmyadmin was used
"Create a database with the same name as the user and grant all permissions to the database created. I don't know how to change the default encoding when creating the database.
Solution: before the first syncdb operation, set the database
Utf8_genenal_ci or utf8_unicode (do not know the difference between them in processing Chinese characters ?).
You can use the following command to create a database:
GBK:CREATE DATABASE tinyCMS DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;
UTF8: CREATE DATABASE tinyCMS DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
When the table is created (but it does not affect the existing table ):
ALTER DATABASE tinyCMS CHARACTER SET utf8 COLLATE utf8_general_ci;
It is very important to specify the encoding when creating a mysql database. Many developers use the default encoding, but developing the encoding of the database can largely avoid the garbled problem caused by import and export.
We should follow the following standards: database, table, field and page or text encoding should be unified.