Django + MySQL - Unknown Encoding: utf8mb4

MySQL 5.5.35 Django 1.6.1

To support emoticons in the database, I configured the parameters of my django:

'OPTIONS': {'charset': 'utf8mb4'} 

Due to MySQL, I get this error: LookupError: unknown encoding: utf8mb4

How do I configure Django / MySQL to support utf8mb4?

+4
source share
2 answers

https://code.djangoproject.com/ticket/18392#comment:10

As a workaround, you can make python understandable to "utf8mb4" as an alias for 'utf8':

 import codecs codecs.register(lambda name: codecs.lookup('utf8') if name == 'utf8mb4' else None) 
+12
source

If you really need utf8mb4, follow the steps in https://mathiasbynens.be/notes/mysql-utf8mb4 and make sure your python package is "MySQL-python" version> = 1.2.5!

+7
source

Source: https://habr.com/ru/post/1244609/


All Articles