aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorXavier Ordoquy2014-07-26 00:06:56 +0200
committerXavier Ordoquy2014-07-26 00:06:56 +0200
commit4876bec9f529cac69aede8e51746d8a0fd6b0d88 (patch)
tree80290706f8c3d5b1c89a763545123cf13709953c /rest_framework/fields.py
parent2489e38a06f575aa144644eee683bd87f20186ef (diff)
parent299a8347e8ef448eefc611eebfe80d7e142ceaa1 (diff)
downloaddjango-rest-framework-4876bec9f529cac69aede8e51746d8a0fd6b0d88.tar.bz2
Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts: rest_framework/fields.py
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index e925c47e..43a74ae6 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -189,7 +189,7 @@ class Field(object):
def field_to_native(self, obj, field_name):
"""
- Given and object and a field name, returns the value that should be
+ Given an object and a field name, returns the value that should be
serialized for that field.
"""
if obj is None:
@@ -470,10 +470,12 @@ class CharField(WritableField):
self.validators.append(validators.MaxLengthValidator(max_length))
def from_native(self, value):
- if value is None and not self.allow_none:
- return ''
if isinstance(value, six.string_types):
return value
+
+ if value is None and not self.allow_none:
+ return ''
+
return smart_text(value)