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
f7d43f53
Commit
f7d43f53
authored
Oct 08, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit blank string -> None to just be on relational fields
parent
5ead8dc8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
rest_framework/fields.py
+0
-4
rest_framework/relations.py
+7
-1
No files found.
rest_framework/fields.py
View file @
f7d43f53
...
...
@@ -110,7 +110,6 @@ class Field(object):
default_validators
=
[]
default_empty_html
=
empty
initial
=
None
coerce_blank_to_null
=
True
def
__init__
(
self
,
read_only
=
False
,
write_only
=
False
,
required
=
None
,
default
=
empty
,
initial
=
empty
,
source
=
None
,
...
...
@@ -248,9 +247,6 @@ class Field(object):
self
.
fail
(
'required'
)
return
self
.
get_default
()
if
data
==
''
and
self
.
coerce_blank_to_null
:
data
=
None
if
data
is
None
:
if
not
self
.
allow_null
:
self
.
fail
(
'null'
)
...
...
rest_framework/relations.py
View file @
f7d43f53
from
rest_framework.compat
import
smart_text
,
urlparse
from
rest_framework.fields
import
Field
from
rest_framework.fields
import
empty
,
Field
from
rest_framework.reverse
import
reverse
from
django.core.exceptions
import
ObjectDoesNotExist
,
ImproperlyConfigured
from
django.core.urlresolvers
import
resolve
,
get_script_prefix
,
NoReverseMatch
,
Resolver404
...
...
@@ -31,6 +31,12 @@ class RelatedField(Field):
)
return
super
(
RelatedField
,
cls
)
.
__new__
(
cls
,
*
args
,
**
kwargs
)
def
run_validation
(
self
,
data
=
empty
):
# We force empty strings to None values for relational fields.
if
data
==
''
:
data
=
None
return
super
(
RelatedField
,
self
)
.
run_validation
(
data
)
def
get_queryset
(
self
):
queryset
=
self
.
queryset
if
isinstance
(
queryset
,
QuerySet
):
...
...
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