On Sun, 2009-03-08 at 18:01 -0700, juanefren wrote: > Right I would mean 1.1 alpha. Looking with more details I found that > error only appears when I use my class __str__ method, for example in > my Address Class I have > > class MyClass(models.Model): > string1 = models.CharField(max_length = 100, null=True) > string2 = models.CharField(max_length = 100, null=True) > def __str__(self) : > return self.string1 +' - ' + self.string2 > > If in my template I use {{ myclass.string1 }} - {{ myclass.string2 }} > Works fine. But if I use {{ myclass }} and either string1 or string2 > has non ascci char, Error appears.
That's expected. The __str__ method is only intended to handle ASCII -- it returns a Python "str" object, not a "unicode" object. That's a Python thing, nothing specific to Django. You should use a __unicode__ method instead. That's why all the examples in the documentation do that, for example. See also, http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.__unicode__ and http://docs.djangoproject.com/en/dev/ref/unicode/ Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---