mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Allow callables in dotted notation like Field(source='foo.bar')
This commit is contained in:
parent
0c65d9babe
commit
d1746e2f3c
|
@ -70,6 +70,8 @@ class Field(object):
|
||||||
value = obj
|
value = obj
|
||||||
for component in self.source.split('.'):
|
for component in self.source.split('.'):
|
||||||
value = getattr(value, component)
|
value = getattr(value, component)
|
||||||
|
if is_simple_callable(value):
|
||||||
|
value = value()
|
||||||
else:
|
else:
|
||||||
value = getattr(obj, field_name)
|
value = getattr(obj, field_name)
|
||||||
return self.to_native(value)
|
return self.to_native(value)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user