diff options
| author | Tom Christie | 2013-08-21 21:31:59 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-08-21 21:31:59 +0100 |
| commit | 16ffdedd14ed842eb019414566705d8b8392ea63 (patch) | |
| tree | cd6fe551725d60b86a57ea5812f60f054e7c1f17 /rest_framework/fields.py | |
| parent | 44ceef841543877a700c3fb4a0f84dfecbad0cbb (diff) | |
| parent | 2bcad32dcb57ae9419f6a901e081f0dcdc1a6f87 (diff) | |
| download | django-rest-framework-16ffdedd14ed842eb019414566705d8b8392ea63.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 8ae8dd4a..518ba41a 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -16,6 +16,7 @@ from django.core import validators from django.core.exceptions import ValidationError from django.conf import settings from django.db.models.fields import BLANK_CHOICE_DASH +from django.http import QueryDict from django.forms import widgets from django.utils.encoding import is_protected_type from django.utils.translation import ugettext_lazy as _ @@ -392,10 +393,15 @@ class BooleanField(WritableField): } empty = False - # Note: we set default to `False` in order to fill in missing value not - # supplied by html form. TODO: Fix so that only html form input gets - # this behavior. - default = False + 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): + self.default = False + + return super(BooleanField, self).field_from_native( + data, files, field_name, into + ) def from_native(self, value): if value in ('true', 't', 'True', '1'): |
