mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Fixed issue #1130: SerializerMethodField now must receive and object or return None
This commit is contained in:
parent
0bbc775b95
commit
29f3f05a45
|
@ -979,5 +979,7 @@ class SerializerMethodField(Field):
|
|||
super(SerializerMethodField, self).__init__()
|
||||
|
||||
def field_to_native(self, obj, field_name):
|
||||
if obj is not None:
|
||||
value = getattr(self.parent, self.method_name)(obj)
|
||||
return self.to_native(value)
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue
Block a user