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
75fbfb58
Commit
75fbfb58
authored
Mar 18, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #739 from craigds/basic-nested-serialization
tweaks to writable nested serializers
parents
ee20cf80
101fa26e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
rest_framework/serializers.py
+6
-2
No files found.
rest_framework/serializers.py
View file @
75fbfb58
...
@@ -129,8 +129,8 @@ class BaseSerializer(WritableField):
...
@@ -129,8 +129,8 @@ class BaseSerializer(WritableField):
_dict_class
=
SortedDictWithMetadata
_dict_class
=
SortedDictWithMetadata
def
__init__
(
self
,
instance
=
None
,
data
=
None
,
files
=
None
,
def
__init__
(
self
,
instance
=
None
,
data
=
None
,
files
=
None
,
context
=
None
,
partial
=
False
,
many
=
None
,
source
=
None
):
context
=
None
,
partial
=
False
,
many
=
None
,
**
kwargs
):
super
(
BaseSerializer
,
self
)
.
__init__
(
source
=
source
)
super
(
BaseSerializer
,
self
)
.
__init__
(
**
kwargs
)
self
.
opts
=
self
.
_options_class
(
self
.
Meta
)
self
.
opts
=
self
.
_options_class
(
self
.
Meta
)
self
.
parent
=
None
self
.
parent
=
None
self
.
root
=
None
self
.
root
=
None
...
@@ -358,6 +358,10 @@ class BaseSerializer(WritableField):
...
@@ -358,6 +358,10 @@ class BaseSerializer(WritableField):
try
:
try
:
value
=
data
[
field_name
]
value
=
data
[
field_name
]
except
KeyError
:
except
KeyError
:
if
self
.
default
is
not
None
and
not
self
.
partial
:
# Note: partial updates shouldn't set defaults
value
=
copy
.
deepcopy
(
self
.
default
)
else
:
if
self
.
required
:
if
self
.
required
:
raise
ValidationError
(
self
.
error_messages
[
'required'
])
raise
ValidationError
(
self
.
error_messages
[
'required'
])
return
return
...
...
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