On Thu, Jan 8, 2009 at 6:14 PM, adrian <adrian.imm...@gmail.com> wrote:

>
> hi,
> i am posting here to follow the "i found a bug" guide ...
>
> let's assume i have a model like this:
>
> -------
> class Test(models.Model):
>    testname = models.CharField(max_length=60, null=False,
> blank=False, unique=True)
>    [... some more fields ...]
>    def __str__(self):
>        return self.testname
> ------
>
> this models works perfectly as long as users only use ascii-characters
> in the testname field. as soon as a user (in django.admin) enters a
> german umlaut -for example- an error is thrown like this:
>
> Caught an exception while rendering: ('ascii', u'German Umlaut\xfc',
> 20, 21, 'ordinal not in range(128)')
>
> this error is reproducable with different database backends (i tested
> sqlite3 and psycopg2) and the model above is reduced to the minimum to
> reproduce. (probably you could remove null, blank and unique
>
> i don't know where the error is produced, wether it is when the
> template uses something like {{Test}} because {{Test.testname}}
> works ... if 'testname' is used as foreignkey in other models and the
> admin interface wants to render this as a dropdown with probably
> something like <option='{{Test.pk}}">{{Test}}</option> this generates
> errors.
>
> so please help me if this is a bug ... :D
>

(You do not mention what version of Django you are using.  I am assuming
something later than 0.96.)

The bug is you have not defined a __unicode__ method for your model:

http://docs.djangoproject.com/en/dev/ref/unicode/#choosing-between-str-and-unicode

Karen

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to