From e299ac0cae6623df3fe4c5fe26f2c1c3db8be1d6 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 21 Dec 2010 06:05:40 +0000 Subject: Reverting r14994 (at request of SmileyChris) because of some backwards compatibility issues that need to be resolved. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14995 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/serializers/python.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'django/core/serializers/python.py') diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py index 839fee12a9..a68ea21f78 100644 --- a/django/core/serializers/python.py +++ b/django/core/serializers/python.py @@ -27,13 +27,11 @@ class Serializer(base.Serializer): self._current = {} def end_object(self, obj): - data = { - "model": smart_unicode(obj._meta), - "fields": self._current - } - if not self.use_natural_keys or not hasattr(obj, 'natural_key'): - data['pk'] = smart_unicode(obj._get_pk_val(), strings_only=True) - self.objects.append(data) + self.objects.append({ + "model" : smart_unicode(obj._meta), + "pk" : smart_unicode(obj._get_pk_val(), strings_only=True), + "fields" : self._current + }) self._current = None def handle_field(self, obj, field): @@ -84,9 +82,7 @@ def Deserializer(object_list, **options): for d in object_list: # Look up the model and starting build a dict of data for it. Model = _get_model(d["model"]) - data = {} - if 'pk' in d: - data[Model._meta.pk.attname] = Model._meta.pk.to_python(d['pk']) + data = {Model._meta.pk.attname : Model._meta.pk.to_python(d["pk"])} m2m_data = {} # Handle each field @@ -131,9 +127,7 @@ def Deserializer(object_list, **options): else: data[field.name] = field.to_python(field_value) - obj = base.build_instance(Model, data, db) - - yield base.DeserializedObject(obj, m2m_data) + yield base.DeserializedObject(Model(**data), m2m_data) def _get_model(model_identifier): """ -- cgit v1.3