18👍
https://code.djangoproject.com/ticket/18392#comment:10
As a workaround, you can make python understand ‘utf8mb4’ as an alias
for ‘utf8’:import codecs codecs.register(lambda name: codecs.lookup('utf8') if name == 'utf8mb4' else None)
11👍
If you really need utf8mb4,
follow the steps in https://mathiasbynens.be/notes/mysql-utf8mb4, and
make sure your python package “MySQL-python” version is >= 1.2.5 !
- Django: Giving validation error feedback on a form after a post redirect get
- Django admin page doesn't show tables of database (djangobook chapter 06)
- Installing PyGObject via pip in virtualenv
- Can i use celery without django
0👍
Fast and easy way.
connection = mysql.connector.connect(user='username',
password='mypass',
host='localhost',
database='mydb',
use_pure=True,
charset='utf8'
)
- How to configure Apache to run ASGI in Django Channels? Is Apache even required?
- Django ORM leaks connections when using ThreadPoolExecutor
-1👍
This worked in my case (MySQL 5.7 + Django 3.1):
Configure Django:
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'charset': 'utf8mb4'
}
Configure MySQL database
- make sure all db tables are using InnoDB storage engine (this is important; the next step will probably fail if you skip it)
- change the Collation for all your tables to utf8mb4_general_ci
- How to correctly use assertRaises in Django
- Deploy-time commands inside Docker on Elastic Beanstalk
- 'WSGIRequest' object has no attribute 'Post'
Source:stackexchange.com