aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2014-12-17 15:24:01 +0000
committerTom Christie2014-12-17 15:24:01 +0000
commitad6533e554663a4c6c40fb02c7d7341fb5afe47f (patch)
tree107d0736824ab8000e26ea4e4be6ef13075d706b /rest_framework
parentffc099a2561be259e6ca378886c0e969a2b5db94 (diff)
parent3fff5cb6e0960b7ff8abd9f13a075f1f057de0a7 (diff)
downloaddjango-rest-framework-ad6533e554663a4c6c40fb02c7d7341fb5afe47f.tar.bz2
Merge pull request #2294 from tomchristie/fix-empty-html-values-with-default
Fix empty HTML values when a default is provided.
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/fields.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index f3e17b18..5be2a21b 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -185,8 +185,13 @@ class Field(object):
self.allow_null = allow_null
if allow_null and self.default_empty_html is empty:
+ # HTML input cannot represent `None` values, so we need to
+ # forcibly coerce empty HTML values to `None` if `allow_null=True`.
self.default_empty_html = None
+ if default is not empty:
+ self.default_empty_html = default
+
if validators is not None:
self.validators = validators[:]