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 == '*':
|
if self.source == '*':
|
||||||
return self.to_native(obj)
|
return self.to_native(obj)
|
||||||
|
|
||||||
if self.source:
|
source = self.source or field_name
|
||||||
value = obj
|
value = obj
|
||||||
for component in self.source.split('.'):
|
|
||||||
value = get_component(value, component)
|
for component in source.split('.'):
|
||||||
else:
|
value = get_component(value, component)
|
||||||
value = get_component(obj, field_name)
|
if value is None:
|
||||||
|
break
|
||||||
|
|
||||||
return self.to_native(value)
|
return self.to_native(value)
|
||||||
|
|
||||||
def to_native(self, value):
|
def to_native(self, value):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user