From 609014460861fdfe82054551790d6439292dde7b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 26 Sep 2014 14:32:44 +0100 Subject: Simplify serialization slightly --- rest_framework/fields.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'rest_framework/fields.py') 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): """ -- cgit v1.2.3