I just chatted with Google and got everything that works for our instance!
The standard way to get utf8mb4 to work in Django is to specify it as DATABASES ['default'] ['OPTIONS'] in settings.py, for example:
'OPTIONS': {'charset': 'utf8mb4'},
This raises an OperationalError in the App Engine, on MySQLdb 1.2.4b4 / 1.2.4 / 1.2.5; which obviously means that the utf8mb4 character set is missing in the MySQL C compiler to compile Google C.
Uncheck this option.
The workaround is to manually call SET NAMES; edit lib / django / db / backends / mysql / base.py and add the line conn.query ("SET NAMES utf8mb4") to DatabaseWrapper.get_new_connection so that 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 utf8mb4 is also included in the backend. The migration commands in the Django App Engine tutorial lead to the Cloud SQL instance configured for utf8. I needed to run these commands in order to include utf8mb4 in two tables:
ALTER TABLE polls_question CONVERT TO CHARACTER SET utf8mb4; ALTER TABLE polls_choice CONVERT TO CHARACTER SET utf8mb4;
source share