aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index cf42d36c..4c49aaba 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -202,12 +202,15 @@ class Field(object):
return self.default_empty_html if (ret == '') else ret
return dictionary.get(self.field_name, empty)
- def get_attribute(self, instance):
+ def get_field_representation(self, instance):
"""
- Given the *outgoing* object instance, return the value for this field
- that should be returned as a primative value.
+ Given the outgoing object instance, return the primative value
+ that should be used for this field.
"""
- return get_attribute(instance, self.source_attrs)
+ attribute = get_attribute(instance, self.source_attrs)
+ if attribute is None:
+ return None
+ return self.to_representation(attribute)
def get_default(self):
"""