I have a project written in Django. All fields that are supposed to store some strings are supposed to be in UTF-8, however, when I run
manage.py syncdb
all respective columns are created with cp1252 character set (where did it get that -- I have no idea) and I have to manually update every column...
Is there a way to tell Django to create all those columns with UTF-8 encoding in the first place?
BTW, I use MySQL.
Django does not specify charset and collation in CREATE TABLE
statements. Everything is determined by database charset. Doing ALTER DATABASE ... CHARACTER SET utf8 COLLATE utf8_general_ci
before running syncdb
should help.
For connection, Django issues SET NAMES utf8
automatically, so you don't need to worry about default connection charset settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With