On Mon, 2008-09-01 at 08:37 -0700, Paolo Corti wrote: > Hi all > > I am a beginner using Django from the trunk and Postgres 8.2 > > I have this issue with utf8, you can replicate it this way (it is > something similiar to this with MySql i guess: > http://groups.google.com/group/django-users/browse_frm/thread/d7dd21493ab5f1fa/a0bd99e381d9de2a?tvc=1&q=encoding+admin#a0bd99e381d9de2a) > > 1) create a postgres db like this: > > CREATE DATABASE test2 > WITH ENCODING='UTF8' > OWNER=test; > > 2) create a django project > > django-admin.py startproject testutf > > 3) configure the settings.py file for the database access and enable > the admin application > > 4) create a test application > > python manage.py startapp apptestutf > > 5) create this simple model > > from django.db import models > > class Person(models.Model): > name = models.CharField('name', max_length=100) > > def __str__(self): > return '%s' % self.name
So as soon as you see UnicodeDecodeError, you should immediately think "where am I passing a unicode object to something that can only handle bytestrings." The __str__ method is certainly one of those cases. Best to follow the Django documentation here and write a __unicode__ method for your model (not a __str__ method). Refer to the first two sections here (or the /unicode documentation) for details: http://www.djangoproject.com/documentation/model-api/#str And, yes, those sections are arguably backwards, since it explains __str__ and then effectively says "don't bother doing that" in a confusing fashion. That will be fixed at some point. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---