[Django]-Python3+Django1.10+mysqlclient1.3.9: cannot save emoji characters

5👍

Setting DATABASE section in the settings.py with OPTIONS – charset solves this issue:

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = { 
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'myproject',
        'HOST': 'mysql',
        'USER': 'django',
        'PASSWORD': '******',
        'OPTIONS': {
            # !!!!!! THIS MATTERS !!!!!!
            'charset': 'utf8mb4',
        }
    },  
}

See documentation: https://docs.djangoproject.com/en/1.10/ref/settings/#charset

Leave a comment