Django DatabaseError invalid byte sequence for encoding “UTF8”

Wow this debugging lead me nowhere.

invalid byte sequence for encoding “UTF8”:
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by “client_encoding”.

If you’re getting a DatabaseError, double check that you are not trying to store pickled data through the ORM. The python docs are wrong about pickle protocol 0 being ASCII only and pickle.dumps(u’©∆∂ƒ©˙∆˚’) will output non ASCII.

bug tracked here: http://bugs.python.org/issue2980

Causing a tough to track error at the DB level which does not consistently appear until a “bad” string is passed in.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s