Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #14888 -- Removing duplicated code in serialisers. Thanks to er…

…ic.fortin.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15163 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 614672d365d6761353dbd11a8967a254d97035b7 1 parent 1ad644c
@andrewgodwin andrewgodwin authored
View
6 django/core/serializers/base.py
@@ -31,9 +31,9 @@ def serialize(self, queryset, **options):
"""
self.options = options
- self.stream = options.get("stream", StringIO())
- self.selected_fields = options.get("fields")
- self.use_natural_keys = options.get("use_natural_keys", False)
+ self.stream = options.pop("stream", StringIO())
+ self.selected_fields = options.pop("fields", None)
+ self.use_natural_keys = options.pop("use_natural_keys", False)
self.start_serialization()
for obj in queryset:
View
3  django/core/serializers/json.py
@@ -18,9 +18,6 @@ class Serializer(PythonSerializer):
internal_use_only = False
def end_serialization(self):
- self.options.pop('stream', None)
- self.options.pop('fields', None)
- self.options.pop('use_natural_keys', None)
simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
def getvalue(self):
View
3  django/core/serializers/pyyaml.py
@@ -38,9 +38,6 @@ def handle_field(self, obj, field):
super(Serializer, self).handle_field(obj, field)
def end_serialization(self):
- self.options.pop('stream', None)
- self.options.pop('fields', None)
- self.options.pop('use_natural_keys', None)
yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options)
def getvalue(self):
Please sign in to comment.
Something went wrong with that request. Please try again.