Andrew wrote:
> 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 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 テスト 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
> print out something I've saved in a file for example.
> 
> Any ideas on where I'm going wrong?
> 
Are you declaring the encoding of your source file?

Try putting

# -*- coding: UTF-8 -*-

at the top of your file.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

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

Reply via email to