mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Traverse the method resolution order when mapping serializer fields.
This commit is contained in:
parent
82d4b20832
commit
ae84b8b0e8
|
@ -904,13 +904,11 @@ class ModelSerializer(Serializer):
|
||||||
for attribute in attributes:
|
for attribute in attributes:
|
||||||
kwargs.update({attribute: getattr(model_field, attribute)})
|
kwargs.update({attribute: getattr(model_field, attribute)})
|
||||||
|
|
||||||
try:
|
for model_field_baseclass in inspect.getmro(model_field.__class__):
|
||||||
return self.field_mapping[model_field.__class__](**kwargs)
|
serializer_field_class = self.field_mapping.get(model_field_baseclass)
|
||||||
except KeyError:
|
if serializer_field_class:
|
||||||
for model_field_class, serializer_field_class in self.field_mapping.items():
|
return serializer_field_class(**kwargs)
|
||||||
if isinstance(model_field, model_field_class):
|
return ModelField(model_field=model_field, **kwargs)
|
||||||
return serializer_field_class(**kwargs)
|
|
||||||
return ModelField(model_field=model_field, **kwargs)
|
|
||||||
|
|
||||||
def get_validation_exclusions(self, instance=None):
|
def get_validation_exclusions(self, instance=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user