Clean up field_to_native logic

This commit is contained in:
Tom Christie 2013-02-12 22:59:01 +00:00
parent 724906c516
commit f505b2e440

View File

@ -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):