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
47a22a55
Commit
47a22a55
authored
Jul 25, 2015
by
Ion Scerbatiuc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a possible fix
parent
46b65d16
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
rest_framework/relations.py
+9
-2
No files found.
rest_framework/relations.py
View file @
47a22a55
...
@@ -13,7 +13,9 @@ from django.utils.six.moves.urllib import parse as urlparse
...
@@ -13,7 +13,9 @@ from django.utils.six.moves.urllib import parse as urlparse
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework.compat
import
OrderedDict
from
rest_framework.compat
import
OrderedDict
from
rest_framework.fields
import
Field
,
empty
,
get_attribute
from
rest_framework.fields
import
(
Field
,
empty
,
get_attribute
,
is_simple_callable
)
from
rest_framework.reverse
import
reverse
from
rest_framework.reverse
import
reverse
from
rest_framework.utils
import
html
from
rest_framework.utils
import
html
...
@@ -106,7 +108,12 @@ class RelatedField(Field):
...
@@ -106,7 +108,12 @@ class RelatedField(Field):
# Optimized case, return a mock object only containing the pk attribute.
# Optimized case, return a mock object only containing the pk attribute.
try
:
try
:
instance
=
get_attribute
(
instance
,
self
.
source_attrs
[:
-
1
])
instance
=
get_attribute
(
instance
,
self
.
source_attrs
[:
-
1
])
return
PKOnlyObject
(
pk
=
instance
.
serializable_value
(
self
.
source_attrs
[
-
1
]))
value
=
instance
.
serializable_value
(
self
.
source_attrs
[
-
1
])
if
is_simple_callable
(
value
):
value
=
value
()
.
pk
return
PKOnlyObject
(
pk
=
value
)
except
AttributeError
:
except
AttributeError
:
pass
pass
...
...
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