Domanda

I encountered this problem. When I cannot assign a unicode string to models.CharField .

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

I found this solution, but it doesn't seem to work for me. The database returns this error:

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

Moreover, all these solutions appear to only work after the table is created, or modify the python manage.py sql APP_NAME output and manually create the tables.

Is there a way to fix this from when originally declaring the django models in the python code, so manage.py syncdb will just produce the right tables?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top