mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54: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
|
||||
for component in self.source.split('.'):
|
||||
value = getattr(value, component)
|
||||
if is_simple_callable(value):
|
||||
value = value()
|
||||
else:
|
||||
value = getattr(obj, field_name)
|
||||
return self.to_native(value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user