#18214: Serializers do not serialize iterators
--------------------------------------+------------------------------------
     Reporter:  moritzs               |      Owner:  nobody
         Type:  Bug                   |     Status:  new
    Component:  Core (Serialization)  |    Version:  SVN
     Severity:  Normal                |   Keywords:  serialization json xml
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+------------------------------------
 According to [https://docs.djangoproject.com/en/dev/topics/serialization/
 serialization documentation] the given object "can be any iterator that
 yields Django objects, but it'll almost always be a !QuerySet". But it
 does not work with iterators.

 Example:
 {{{
 #!python
 >>> from django.core import serializers
 >>> json_serializer = serializers.get_serializer('json')()
 >>> json_serializer.serialize([1, 2, 3])
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "trunk/django/core/serializers/base.py", line 46, in serialize
     concrete_model = obj._meta.concrete_model
 AttributeError: 'int' object has no attribute '_meta'
 >>>
 >>> xml_serializer = serializers.get_serializer('xml')()
 >>> xml_serializer.serialize([1, 2, 3])
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "trunk/django/core/serializers/base.py", line 43, in serialize
     self.start_object(obj)
   File "trunk/django/core/serializers/xml_serializer.py", line 42, in
 start_object
     raise base.SerializationError("Non-model object (%s) encountered
 during serialization" % type(obj))
 SerializationError: Non-model object (<type 'int'>) encountered during
 serialization
 }}}
 One should either change the documentation or make this work.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18214>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to