diff options
| author | Tom Christie | 2014-09-26 14:32:44 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-09-26 14:32:44 +0100 |
| commit | 609014460861fdfe82054551790d6439292dde7b (patch) | |
| tree | 3cae8ee2cf583a0790294a7f4ced79483bb3c7b5 /rest_framework/fields.py | |
| parent | 8be4496586519f84b839b07efc74148a3559349e (diff) | |
| download | django-rest-framework-609014460861fdfe82054551790d6439292dde7b.tar.bz2 | |
Simplify serialization slightly
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 11 |
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): """ |
