Ticket #2701: serialize_limit_by_field.diff
File serialize_limit_by_field.diff, 1.3 KB (added by , 18 years ago) |
---|
-
django/core/serializers/base.py
28 28 self.options = options 29 29 30 30 self.stream = options.get("stream", StringIO()) 31 self.selected_fields = options.get("fields") 31 32 32 33 self.start_serialization() 33 34 for obj in queryset: … … 36 37 if field is obj._meta.pk: 37 38 continue 38 39 elif field.rel is None: 39 self.handle_field(obj, field) 40 if self.selected_fields is None or field.attname in self.selected_fields: 41 self.handle_field(obj, field) 40 42 else: 41 self.handle_fk_field(obj, field) 43 if self.selected_fields is None or field.attname[:-3] in self.selected_fields: 44 self.handle_fk_field(obj, field) 42 45 for field in obj._meta.many_to_many: 43 self.handle_m2m_field(obj, field) 46 if self.selected_fields is None or field.attname in self.selected_fields: 47 self.handle_m2m_field(obj, field) 44 48 self.end_object(obj) 45 49 self.end_serialization() 46 50 return self.getvalue()