0

我遇到了这个问题。当我无法将 unicode 字符串分配给models.CharField.

DatabaseError: (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")

我找到了这个解决方案,但它似乎对我不起作用。数据库返回此错误:

Error Code: 1025. Error on rename of './test_database/#sql-272e_1ba' to './test_database/[MY_TABLE_NAME]' (errno: 150)

此外,所有这些解决方案似乎只有在创建表后才能工作,或者修改 python manage.py sql APP_NAME 输出并手动创建表。

有没有办法从最初在 python 代码中声明 django 模型时解决这个问题,所以 manage.py syncdb 只会生成正确的表?

4

1 回答 1

0

This seems to be an issue with your database configuration, not with Django. My guess is that whatever DB you're using, it's configured to use latin1_swidish_ci for new tables. You can hook syncdb and alter the table there, but I think your better off fixing your DB config directly.

于 2013-01-11T07:08:53.813 回答