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
41ac1e8f
Commit
41ac1e8f
authored
Feb 12, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise warnings if 'request' not in context for hyperlinked fields.
parent
388e6173
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
rest_framework/relations.py
+13
-0
No files found.
rest_framework/relations.py
View file @
41ac1e8f
...
...
@@ -311,6 +311,13 @@ class HyperlinkedRelatedField(RelatedField):
view_name
=
self
.
view_name
request
=
self
.
context
.
get
(
'request'
,
None
)
format
=
self
.
format
or
self
.
context
.
get
(
'format'
,
None
)
if
request
is
None
:
warnings
.
warn
(
"Using `HyperlinkedRelatedField` without including the "
"request in the serializer context is due to be deprecated. "
"Add `context={'request': request}` when instantiating the serializer."
,
PendingDeprecationWarning
,
stacklevel
=
4
)
pk
=
getattr
(
obj
,
'pk'
,
None
)
if
pk
is
None
:
return
...
...
@@ -420,6 +427,12 @@ class HyperlinkedIdentityField(Field):
view_name
=
self
.
view_name
or
self
.
parent
.
opts
.
view_name
kwargs
=
{
self
.
pk_url_kwarg
:
obj
.
pk
}
if
request
is
None
:
warnings
.
warn
(
"Using `HyperlinkedIdentityField` without including the "
"request in the serializer context is due to be deprecated. "
"Add `context={'request': request}` when instantiating the serializer."
,
PendingDeprecationWarning
,
stacklevel
=
4
)
# By default use whatever format is given for the current context
# unless the target is a different type to the source.
#
...
...
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