diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-12-21 06:05:40 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-12-21 06:05:40 +0000 |
| commit | e299ac0cae6623df3fe4c5fe26f2c1c3db8be1d6 (patch) | |
| tree | 9296e20b767b1349112f520ad0654584516a4160 /django/core/serializers/python.py | |
| parent | b60d5df07266dd4cd4f63afa6986ffb2932facc2 (diff) | |
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
Diffstat (limited to 'django/core/serializers/python.py')
| -rw-r--r-- | django/core/serializers/python.py | 20 |
1 files changed, 7 insertions, 13 deletions
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): """ |
