Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
28ff6fb1
Commit
28ff6fb1
authored
Aug 19, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only HTML forms should have implicit default False for boolean fields
parent
34d65119
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
rest_framework/fields.py
+10
-4
No files found.
rest_framework/fields.py
View file @
28ff6fb1
...
...
@@ -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
_
...
...
@@ -399,10 +400,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'
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment