我遇到了这个问题。当我无法将unicode字符串分配给models.CharField时。
DatabaseError: (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")我找到了this solution,但它似乎不适合我。数据库返回此错误:
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输出并手动创建表。
当最初在manage.py代码中声明django模型时,有没有办法解决这个问题,以便python syncdb只生成正确的表?
发布于 2013-01-11 15:08:54
这似乎是数据库配置的问题,而不是Django的问题。我的猜测是,无论您使用的是什么数据库,它都被配置为对新表使用latin1_swidish_ci。您可以在那里对表进行hook syncdb和修改,但我认为最好直接修复您的DB配置。
https://stackoverflow.com/questions/14273003
复制相似问题