jeffci
jeffci

Reputation: 2622

How do I fix Exception Type: UnicodeEncodeError

I am not sure why I am getting this error:

Exception Type: UnicodeEncodeError

Unicode error hint
The string that could not be encoded/decoded was: he Théâtre d

The full traceback is here: http://dpaste.com/686751/ (I put it in a dpaste due to it's length)

I am really confused about this because it works flawlessly on our staging and has been for a year or so now, it's finally on the live server, I copied over the database to the live server and now if I edit anything or add a new page with any sort of french accents I received the above error. I've been googling for hours with not much luck.

In my research I have found some issues with DB collation but I have tried to recreate the database as utf8_general_ci, and converted the tables respectively and still no luck. Any idea?

I should also note that the apps listed in the installed apps are one's we've developed and use for about 13 other live and large web sites on the same server and with the same types of characters.

baffled

Jeff

Upvotes: 2

Views: 7463

Answers (2)

user4113780
user4113780

Reputation: 21

in model add u''

def __unicode__(self):
    return u"%s" % self.your_field

Upvotes: 2

Karolina Hidalgo
Karolina Hidalgo

Reputation: 52

maybe the servers have different library versions? afaik, the way to fix those errors is using the smart_unicode function in the unicode method in models, as mentioned here: django unicode encode/decode errors

Upvotes: 1

Related Questions