aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2014-12-17 15:13:48 +0000
committerTom Christie2014-12-17 15:13:48 +0000
commit3fff5cb6e0960b7ff8abd9f13a075f1f057de0a7 (patch)
tree8e3e795810ca0277539829849d70b85986bd93d6 /rest_framework/fields.py
parent426547c61c725ca7dc47671c084d1a2805c92305 (diff)
downloaddjango-rest-framework-3fff5cb6e0960b7ff8abd9f13a075f1f057de0a7.tar.bz2
Fix empty HTML values when a default is provided.
Diffstat (limited to 'rest_framework/fields.py')
-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[:]