Hi people,

I'm trying to use the serialize utils at
django.core.serializers.xml_serialize and
django.core.serializers.json, i don't have problems using json but i
have issues trying something like that:

xml = serializers.serialize("xml", Anymodel.objects.all())

If the model data contains unicode characters (example:
Anymodel.name='Ñ'). The error is the following:

-------
exceptions.UnicodeDecodeError                        Traceback (most
recent call last)

/usr/local/lib/python2.4/site-packages/django/core/serializers/
__init__.py in serialize(format, queryset, **options)
     65     """
     66     s = get_serializer(format)()
---> 67     s.serialize(queryset, **options)
     68     return s.getvalue()
     69

/usr/local/lib/python2.4/site-packages/django/core/serializers/base.py
in serialize(self, queryset, **options)
     38                     if field.rel is None:
     39                         if self.selected_fields is None or
field.attname in self.selected_fields:
---> 40                             self.handle_field(obj, field)
     41                     else:
     42                         if self.selected_fields is None or
field.attname[:-3] in self.selected_fields:

/usr/local/lib/python2.4/site-packages/django/core/serializers/
xml_serializer.py in handle_field(self, obj, field)
     70             value = self.get_string_value(obj, field)
     71             self.xml.characters(str(value))
---> 72         else:
     73             self.xml.addQuickElement("None")
     74

/usr/lib/python2.4/site-packages/_xmlplus/sax/saxutils.py in
characters(self, content)
    307
    308     def characters(self, content):
--> 309         writetext(self._out, content)
    310
    311     def ignorableWhitespace(self, content):

/usr/lib/python2.4/site-packages/_xmlplus/sax/saxutils.py in
writetext(stream, text, entities)
    186     def writetext(stream, text, entities={}):
    187         stream.errors = "xmlcharrefreplace"
--> 188         stream.write(escape(text, entities))
    189         stream.errors = "strict"
    190 else:

/usr/lib/python2.4/codecs.py in write(self, object)
    176         """ Writes the object's contents encoded to
self.stream.
    177         """
--> 178         data, consumed = self.encode(object, self.errors)
    179         self.stream.write(data)
    180

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
54: ordinal not in range(128)
------
I'm using version from svn (rev. 4997) and the default charset, utf-8.

I couldn't find any post about that...

Any idea? I'm a real noob in unicode things. Anyone with the same
problem?

Thx a lot in advance,
Saik


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