aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2014-06-27 16:39:54 +0100
committerTom Christie2014-06-27 16:39:54 +0100
commit8eadac39adcf0e0f1981d0a07acd30268ba4f03a (patch)
tree6df4c5adf05460fc2949e74efbc57dec80d789dc /rest_framework/fields.py
parent636ae419be2882dbec8151b6baa60bde118faede (diff)
parent3326ddc865154b0c09fc3bb0da2644f0dfc3bc24 (diff)
downloaddjango-rest-framework-8eadac39adcf0e0f1981d0a07acd30268ba4f03a.tar.bz2
Merge pull request #1665 from smal/modelserialization-charfield-with-null
Modelserialization charfield with null
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index d5c8134b..6caae924 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -474,8 +474,12 @@ class CharField(WritableField):
self.validators.append(validators.MaxLengthValidator(max_length))
def from_native(self, value):
- if isinstance(value, six.string_types) or value is None:
+ if isinstance(value, six.string_types):
return value
+
+ if value is None:
+ return ''
+
return smart_text(value)