I am currently working through the django book and I've got to the
fifth chapter where I would like to replace the __str__() methods with
__unicode__() methods instead. The reason is that my database will
hold a great deal of Japanese text, UTF-8 encoded. After declaring the
UTF-8 encoding at the top of models.py, as a test, I replace

def __str__(self):
    return self.name

with

def __unicode__(self):
    return u'テスト'

Entering the following code (from the django book) into the manage.py
shell doesn't give the expected output.

>>> from books.models import Publisher
>>> publisher_list = Publisher.objects.all()
>>> publisher_list

I expect:

[<Publisher: テスト>, <Publisher: テスト>]

but instead, the テスト part is replaced with random Japanese characters
that are not the ones I expected.

I am using a Japanese version of Windows XP with PostgreSQL installed.
The encoding of the database and the file are both UTF-8. The cmd.exe
prompt doesn't let me type in Japanese but it does display Japanese if
I print out something I've saved in a file for example.

Any ideas on where I'm going wrong? Apologies if this has been asked
before.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to