21👍
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.
4👍
Django’s database backends automatically handles Unicode strings into the appropriate encoding and talk to the database. You don’t need to tell Django what encoding your database uses. It handles it well, by using you database’s encoding.
I don’t see any way you can tell django to create a column, using some specific encoding.
As it appears to me, there is absolutely some previous MySQL configuration affecting you.
And despite of doing it manually for all column, use these.
CREATE DATABASE db_name
[[DEFAULT] CHARACTER SET charset_name]
[[DEFAULT] COLLATE collation_name]
ALTER DATABASE db_name
[[DEFAULT] CHARACTER SET charset_name]
[[DEFAULT] COLLATE collation_name]
- Django Channels Error – Cannot import BACKEND 'asgi_redis.RedisChannelLayer'
- Heroku/python failed to detect set buildpack
2👍
What is your MySQL encoding set to?
For example, try the following from the command line:
mysqld --verbose --help | grep character-set
If it doesn’t output utf8, then you’ll need to set the output in my.cnf:
[mysqld]
character-set-server=utf8
default-collation=utf8_unicode_ci
[client]
default-character-set=utf8
This page has some more information:
- Django – How to simply get domain name?
- How do I get django runserver to show me DeprecationWarnings and other useful messages?
- Django extract string from [ErrorDetail(string='Test Message', code='invalid')]
- Validation on query_params in Django Rest Framework
- Fix Conflicting migrations detected in Django1.9