mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Clean up field_to_native logic
This commit is contained in:
parent
724906c516
commit
f505b2e440
|
@ -94,12 +94,14 @@ class Field(object):
|
|||
if self.source == '*':
|
||||
return self.to_native(obj)
|
||||
|
||||
if self.source:
|
||||
value = obj
|
||||
for component in self.source.split('.'):
|
||||
value = get_component(value, component)
|
||||
else:
|
||||
value = get_component(obj, field_name)
|
||||
source = self.source or field_name
|
||||
value = obj
|
||||
|
||||
for component in source.split('.'):
|
||||
value = get_component(value, component)
|
||||
if value is None:
|
||||
break
|
||||
|
||||
return self.to_native(value)
|
||||
|
||||
def to_native(self, value):
|
||||
|
|
Loading…
Reference in New Issue
Block a user