On Sep 16, 6:50 pm, "Gabriel ." <gabriel....@gmail.com> wrote: > Hello, > > I have this method defined in a model: > > def __repr__(self): > return ugettext_lazy("%(file)s (Component: %(component)s - > Release: %(release)s)") % { > 'file': self.filename, > 'component': self.component.name, > 'release': self.release.name,} > > (I tried also with ugettext) > > I'm getting an UnicodeEncodeError when I call this method and the > language is Portuguese (the translated version is: "%(file)s > (componente: %(component)s - versão: %(release)s)"). The 'ã' is > causing problems here, but only here, I'm using the same string in a > view and it works ok. > > My question is, why is it failing only in the repr method? > > -- > Kind Regards
Try putting a u just before the open quote: return ugettext_lazy(u"%(file)s (Component: %(component)s - Release: %(release)s)") I don't know much about ugettext_lazy, but often unicode errors are caused by using bytestrings where you should be using unicode strings. -- DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---