Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
django模型数据库排序问题:声明一个支持unicode的字段?_Django_Django Models_Collation_Django Database - Fatal编程技术网

django模型数据库排序问题:声明一个支持unicode的字段?

django模型数据库排序问题:声明一个支持unicode的字段?,django,django-models,collation,django-database,Django,Django Models,Collation,Django Database,我遇到了这个问题。当我无法将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_data

我遇到了这个问题。当我无法将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只生成正确的表

这似乎是数据库配置的问题,而不是Django的问题。我的猜测是,无论您使用什么DB,它都配置为在新表中使用latin1_swidish_ci。你可以在那里修改表,但是我认为你最好直接修改数据库配置