diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
index c97ab62..55c6292 100644
a
|
b
|
class Serializer(base.Serializer):
|
37 | 37 | self._current = None |
38 | 38 | |
39 | 39 | def get_dump_object(self, obj): |
40 | | data = OrderedDict([('model', force_text(obj._meta))]) |
| 40 | model = obj._meta.proxy_for_model if obj._deferred else obj.__class__ |
| 41 | data = OrderedDict([('model', force_text(model._meta))]) |
41 | 42 | if not self.use_natural_primary_keys or not hasattr(obj, 'natural_key'): |
42 | 43 | data["pk"] = force_text(obj._get_pk_val(), strings_only=True) |
43 | 44 | data['fields'] = self._current |
diff --git a/django/core/serializers/xml_serializer.py b/django/core/serializers/xml_serializer.py
index 9a4bd77..9dfd8e7 100644
a
|
b
|
class Serializer(base.Serializer):
|
52 | 52 | raise base.SerializationError("Non-model object (%s) encountered during serialization" % type(obj)) |
53 | 53 | |
54 | 54 | self.indent(1) |
55 | | attrs = OrderedDict([("model", smart_text(obj._meta))]) |
| 55 | model = obj._meta.proxy_for_model if obj._deferred else obj.__class__ |
| 56 | attrs = OrderedDict([("model", smart_text(model._meta))]) |
56 | 57 | if not self.use_natural_primary_keys or not hasattr(obj, 'natural_key'): |
57 | 58 | obj_pk = obj._get_pk_val() |
58 | 59 | if obj_pk is not None: |
diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py
index 505e599..bd688d9 100644
a
|
b
|
class SerializersTestBase(object):
|
224 | 224 | serial_str)) |
225 | 225 | self.assertEqual(deserial_objs[0].object.score, Approximate(3.4, places=1)) |
226 | 226 | |
| 227 | def test_deferred_field_serialization(self): |
| 228 | author = Author.objects.create(name='Victor Hugo') |
| 229 | author = Author.objects.defer('name').get(pk=author.pk) |
| 230 | serial_str = serializers.serialize(self.serializer_name, [author]) |
| 231 | deserial_objs = list(serializers.deserialize(self.serializer_name, serial_str)) |
| 232 | self.assertEqual(deserial_objs[0].object.__class__, Author) |
| 233 | |
227 | 234 | def test_custom_field_serialization(self): |
228 | 235 | """Tests that custom fields serialize and deserialize intact""" |
229 | 236 | team_str = "Spartak Moskva" |