diff options
| author | Kevin Brown | 2013-12-13 12:41:44 -0500 |
|---|---|---|
| committer | Kevin Brown | 2013-12-13 13:20:29 -0500 |
| commit | 90edcbf938ed8d6f3b783372c17e60bbf0761b61 (patch) | |
| tree | fc7706a16f563b1941d09bd708ad449be7fba218 /rest_framework/fields.py | |
| parent | ca244ad614e2f6fb4fef1dc9987be996d2624303 (diff) | |
| download | django-rest-framework-90edcbf938ed8d6f3b783372c17e60bbf0761b61.tar.bz2 | |
Fix default values always being False for browsable API
This fixes a bug that was introduced in 28ff6fb [1] for the
browsable API, specifically with how it handled default values
for boolean fields. Previously, it had a global default for
boolean fields set to `False`, which was different than the
standard None that was used elsewhere. Because this only needed
to be done for the browsable API, a fix was put into place that
only set the default to `False` when form data was passed into
the serializer. This had the unintended side effect of overriding
any default set on the boolean field.
This fixes #1101 [2] by only overriding the default if the default is
`None`, which is the default for all fields.
[1]: https://github.com/tomchristie/django-rest-framework/commit/28ff6fb1ec02b7a04c4a0db54885f3735b6dd43f
[2]: https://github.com/tomchristie/django-rest-framework/issues/1101
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5a4f04a5..f1de447c 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -428,7 +428,7 @@ class BooleanField(WritableField): def field_from_native(self, data, files, field_name, into): # HTML checkboxes do not explicitly represent unchecked as `False` # we deal with that here... - if isinstance(data, QueryDict): + if isinstance(data, QueryDict) and self.default is None: self.default = False return super(BooleanField, self).field_from_native( |
