pro*_*ock 5 python mysql django unicode mysql-error-1267
出现以下错误的原因是什么?当我尝试过滤:
if MyObject.objects.filter(location = aDictionary['address']):
Run Code Online (Sandbox Code Playgroud)
位置定义为:
location = models.CharField(max_length=100, blank=True, default='')
Run Code Online (Sandbox Code Playgroud)
当aDictionary ['address']包含带有非字母数字字符的字符串(例如Kīhei)时,我收到以下错误:
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaul
terrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1267, "Illegal mix of collations (latin1_sw
edish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")
Run Code Online (Sandbox Code Playgroud)
改变MySQL中的数据库,如下所示:
ALTER TABLE foo CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Run Code Online (Sandbox Code Playgroud)
创建新数据库时,请记住使用正确的整理设置进行创建:
CREATE DATABASE foo CHARACTER SET utf8 COLLATE utf8_general_ci;
Run Code Online (Sandbox Code Playgroud)
这里有更多讨论.
| 归档时间: |
|
| 查看次数: |
1983 次 |
| 最近记录: |