How to make django's mysql connections to use utf8mb4 ?

1,158 views
Skip to first unread message

Chen Xu

unread,
Jan 23, 2013, 4:07:07 PM1/23/13
to django...@googlegroups.com
I saved some Emoji icons to MySQL Database,the icons have been saved correctly. Since I can see them from MySQL Shell when I type 'select message_text from messages'

However, when I do Message.object.get(ph=5).message_text, it shows me a bunch question marks.

Could someone please help?

Thanks

--
⚡ Chen Xu

Adrián Espinosa

unread,
Jan 24, 2013, 2:59:24 AM1/24/13
to django...@googlegroups.com
Hello,

I struggled with this once, although not through Django. I tried a lot of things, and I couldn't get MySQL to properly store emojis, or japanese/chinese characters for example.

As my project was just starting, I switched to postgresql, and it just worked. I did nothing fancy to get it to work and I have succesfully stored all kind of characters.

I'm also interested in the right solution for MySQL, but if you don't want to spend a lot of time or anything else, you might want to try with postgresql.

Best regards

Peter of the Norse

unread,
Feb 18, 2013, 7:22:27 PM2/18/13
to django...@googlegroups.com
Triple check your encoding type on the database and table. MySQL is often stupid about encoding, and when Django tries to do the right thing, it fails. I once converted a MySQL database from PHP to Django, and ran into a similar problem. Everything on the old database was marked Latin1, but web browsers were treating it as UTF-8. MySQL was more than happy to store invalid data, but when it came time to view the data with Django, all we got were random characters and question marks. They were trying to convert Latin1 into UTF-8 and failing. phpMyAdmin did the wrong thing too.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/XMNArBaFugEJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

-- 
Peter of the Norse

Chris Streeter

unread,
Feb 19, 2013, 11:46:21 PM2/19/13
to django...@googlegroups.com
There is some discussion on this ticket:

The ticket also requires that a new version of MySQLdb be running to properly recognize the type.

- Chris


To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages