On 5/16/07, Andreas Ahlenstorf <[EMAIL PROTECTED]> wrote:
> I've some models where the strings returned by __str__() are unicode
> strings and contain non-ascii characters, especially umlauts. With a
> recent Django version, this causes UnicodeEncodeErrors all over the
> place. Could anybody give me a hint on what I have to do to work
> around this issues except using ascii characters only?

Generally, you don't want __str__ to return a Unicode string; if you
need to get Unicode out of it, have it return a UTF-8-encoded
bytestring. To return a Unicode string directly, instead define the
__unicode__ method to return that, and probably a __str__ which
returns the result of __unicode__ encoded as a UTF-8 bytestring.

The notes here may also be of some help:

http://code.djangoproject.com/wiki/UnicodeBranch

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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