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
c124585d
Commit
c124585d
authored
Jun 28, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #219 from scfarley/related-serializers-2
Pass request to related serializers
parents
9dbaac31
1b49c5e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
djangorestframework/serializer.py
+7
-2
No files found.
djangorestframework/serializer.py
View file @
c124585d
...
@@ -179,7 +179,8 @@ class Serializer(object):
...
@@ -179,7 +179,8 @@ class Serializer(object):
stack
=
self
.
stack
[:]
stack
=
self
.
stack
[:]
stack
.
append
(
obj
)
stack
.
append
(
obj
)
return
related_serializer
(
depth
=
depth
,
stack
=
stack
)
.
serialize
(
obj
)
return
related_serializer
(
depth
=
depth
,
stack
=
stack
)
.
serialize
(
obj
,
request
=
self
.
request
)
def
serialize_max_depth
(
self
,
obj
):
def
serialize_max_depth
(
self
,
obj
):
"""
"""
...
@@ -253,11 +254,15 @@ class Serializer(object):
...
@@ -253,11 +254,15 @@ class Serializer(object):
"""
"""
return
smart_unicode
(
obj
,
strings_only
=
True
)
return
smart_unicode
(
obj
,
strings_only
=
True
)
def
serialize
(
self
,
obj
):
def
serialize
(
self
,
obj
,
request
=
None
):
"""
"""
Convert any object into a serializable representation.
Convert any object into a serializable representation.
"""
"""
# Request from related serializer.
if
request
is
not
None
:
self
.
request
=
request
if
isinstance
(
obj
,
(
dict
,
models
.
Model
)):
if
isinstance
(
obj
,
(
dict
,
models
.
Model
)):
# Model instances & dictionaries
# Model instances & dictionaries
return
self
.
serialize_model
(
obj
)
return
self
.
serialize_model
(
obj
)
...
...
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