The standard way to get utf8mb4 working in Django is to specify it as DATABASES['default']['OPTIONS'] in settings.py, like this:
'OPTIONS': {'charset': 'utf8mb4'},
The workaround is to manually call SET NAMES; edit lib/django/db/backends/mysql/base.py and add a conn.query("SET NAMES utf8mb4") line into DatabaseWrapper.get_new_connection, so it looks like this:
def get_new_connection(self, conn_params):
conn = Database.connect(**conn_params)
conn.encoders[SafeText] = conn.encoders[six.text_type]
conn.encoders[SafeBytes] = conn.encoders[bytes]
conn.query("SET NAMES utf8mb4")
return conn
Make sure that you also have utf8mb4 enabled on the backend. The migration commands in the App Engine Django tutorial result in a Cloud SQL instance configured for utf8. I needed to run these commands to enable utf8mb4 on the two tables:
ALTER TABLE ap_ruckus_brushstatus CONVERT TO CHARACTER SET utf8mb4;
ALTER TABLE ap_ruckus_brushstatus CONVERT TO CHARACTER SET utf8mb4;
Let me know if that fixes your problem. There is a real fix in the pipeline but no timetable for it to be out.
The standard way to get utf8mb4 working in Django is to specify it as DATABASES['default']['OPTIONS'] in settings.py, like this: 'OPTIONS': {'charset': 'utf8mb4'},The workaround is to manually ...