Ticket #5711: patch.diff
File patch.diff, 1.9 KB (added by , 17 years ago) |
---|
-
core/serializers/json.py
23 23 def end_serialization(self): 24 24 self.options.pop('stream', None) 25 25 self.options.pop('fields', None) 26 self.options.pop('attrs', None) 26 27 simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options) 27 28 28 29 def getvalue(self): -
core/serializers/base.py
30 30 31 31 self.stream = options.get("stream", StringIO()) 32 32 self.selected_fields = options.get("fields") 33 self.selected_attrs = options.get("attrs", []) 33 34 34 35 self.start_serialization() 35 36 for obj in queryset: … … 46 47 if field.serialize: 47 48 if self.selected_fields is None or field.attname in self.selected_fields: 48 49 self.handle_m2m_field(obj, field) 50 for attr in self.selected_attrs: 51 self.handle_attr(obj, attr) 49 52 self.end_object(obj) 50 53 self.end_serialization() 51 54 return self.getvalue() -
core/serializers/python.py
34 34 35 35 def handle_field(self, obj, field): 36 36 self._current[field.name] = smart_unicode(getattr(obj, field.name), strings_only=True) 37 38 def handle_attr(self, obj, field): 39 self._current[field] = smart_unicode(getattr(obj, field), strings_only=True) 37 40 38 41 def handle_fk_field(self, obj, field): 39 42 related = getattr(obj, field.name)