Some time ago, the following error occurred when porting A Django-Based System from English to Chinese:
Exception value:
(1366, "incorrect string value: '\ xe4 \ xb8 \ XAD \ xe5 \ x9b \ xbd' for column 'groupname' at Row 1 ")
After careful viewing, we know that Chinese characters cannot be written into the database, because the encoding method for the database connected to MySQL is "Latin1", and the encoding method of the created database is also Latin1, to solve this problem, you need to do the following:
1. change my. ini configuration file. Change default-character-set = Latin1 under [MySQL] and [mysqld] To default-character-set = utf8 (do not write it as UTF-8)
2. in addition, it is best to set the database character set to "utf8 -- UTF-8Unicode" when creating a database, so that the new table characters will be "UTF-8 ", otherwise, you must manually modify the attributes of each text class in each table.