[Answered ]-Baffled by python __str__ method and unicode behaviour

2👍

You need to give your model a __unicode__ method that actually returns Unicode:

def __unicode__(self):
   return u"%s %s" % (self.guid, self.setside_username)

Note the u prefix, we used a Unicode literal, and we did not encode the username.

The Django model baseclass provides a __str__ method that’ll take the __unicode__ output and encode it to a bytestring for you.

Leave a comment