diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py
index e4bba1d..dbe7787 100644
a
|
b
|
def serialize(self, queryset, **options):
|
43 | 43 | self.start_object(obj) |
44 | 44 | # Use the concrete parent class' _meta instead of the object's _meta |
45 | 45 | # This is to avoid local_fields problems for proxy models. Refs #17717. |
46 | | concrete_class = obj._meta.proxy_for_model or obj.__class__ |
47 | | for field in concrete_class._meta.local_fields: |
| 46 | concrete_model = obj._meta.concrete_model |
| 47 | for field in concrete_model._meta.local_fields: |
48 | 48 | if field.serialize: |
49 | 49 | if field.rel is None: |
50 | 50 | if self.selected_fields is None or field.attname in self.selected_fields: |
… |
… |
def serialize(self, queryset, **options):
|
52 | 52 | else: |
53 | 53 | if self.selected_fields is None or field.attname[:-3] in self.selected_fields: |
54 | 54 | self.handle_fk_field(obj, field) |
55 | | for field in concrete_class._meta.many_to_many: |
| 55 | for field in concrete_model._meta.many_to_many: |
56 | 56 | if field.serialize: |
57 | 57 | if self.selected_fields is None or field.attname in self.selected_fields: |
58 | 58 | self.handle_m2m_field(obj, field) |
diff --git a/tests/regressiontests/serializers_regress/models.py b/tests/regressiontests/serializers_regress/models.py
index 9381349..f366f90 100644
a
|
b
|
class ProxyBaseModel(BaseModel):
|
263 | 263 | class Meta: |
264 | 264 | proxy = True |
265 | 265 | |
| 266 | class ProxyProxyBaseModel(ProxyBaseModel): |
| 267 | class Meta: |
| 268 | proxy = True |
| 269 | |
266 | 270 | class LengthModel(models.Model): |
267 | 271 | data = models.IntegerField() |
268 | 272 | |
diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
index d8c5fab..704e34b 100644
a
|
b
|
|
41 | 41 | GenericIPAddressPKData, PhonePKData, PositiveIntegerPKData, |
42 | 42 | PositiveSmallIntegerPKData, SlugPKData, SmallPKData, USStatePKData, |
43 | 43 | AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel, BaseModel, |
44 | | ExplicitInheritBaseModel, InheritBaseModel, ProxyBaseModel, BigIntegerData, |
45 | | LengthModel, Tag, ComplexModel) |
| 44 | ExplicitInheritBaseModel, InheritBaseModel, ProxyBaseModel, |
| 45 | ProxyProxyBaseModel, BigIntegerData, LengthModel, Tag, ComplexModel) |
46 | 46 | |
47 | 47 | # A set of functions that can be used to recreate |
48 | 48 | # test data objects of various kinds. |
… |
… |
def test_yaml_deserializer_exception(self):
|
410 | 410 | |
411 | 411 | def test_serialize_proxy_model(self): |
412 | 412 | BaseModel.objects.create(parent_data=1) |
413 | | base_objects = BaseModel.objects.all() |
| 413 | base_objects = BaseModel.objects.all() |
414 | 414 | proxy_objects = ProxyBaseModel.objects.all() |
415 | | base_data = serializers.serialize("json", base_objects) |
| 415 | proxy_proxy_objects = ProxyProxyBaseModel.objects.all() |
| 416 | base_data = serializers.serialize("json", base_objects) |
416 | 417 | proxy_data = serializers.serialize("json", proxy_objects) |
| 418 | proxy_proxy_data = serializers.serialize("json", proxy_proxy_objects) |
417 | 419 | self.assertEqual(base_data, proxy_data.replace('proxy', '')) |
| 420 | self.assertEqual(base_data, proxy_proxy_data.replace('proxy', '')) |
418 | 421 | |
419 | 422 | |
420 | 423 | def serializerTest(format, self): |