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
9d3810f3
Commit
9d3810f3
authored
Dec 10, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop get_iterable()
parent
ca7b1f6d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
rest_framework/relations.py
+3
-6
No files found.
rest_framework/relations.py
View file @
9d3810f3
...
...
@@ -88,7 +88,7 @@ class RelatedField(Field):
return
False
def
get_attribute
(
self
,
instance
):
if
self
.
use_pk_only_optimization
():
if
self
.
use_pk_only_optimization
()
and
self
.
source_attrs
:
try
:
# Optimized case, return a mock object only containing the pk attribute.
instance
=
get_attribute
(
instance
,
self
.
source_attrs
[:
-
1
])
...
...
@@ -99,10 +99,6 @@ class RelatedField(Field):
# Standard case, return the object instance.
return
get_attribute
(
instance
,
self
.
source_attrs
)
def
get_iterable
(
self
,
instance
,
source_attrs
):
relationship
=
get_attribute
(
instance
,
source_attrs
)
return
relationship
.
all
()
if
(
hasattr
(
relationship
,
'all'
))
else
relationship
@property
def
choices
(
self
):
return
dict
([
...
...
@@ -349,7 +345,8 @@ class ManyRelatedField(Field):
]
def
get_attribute
(
self
,
instance
):
return
self
.
child_relation
.
get_iterable
(
instance
,
self
.
source_attrs
)
relationship
=
get_attribute
(
instance
,
self
.
source_attrs
)
return
relationship
.
all
()
if
(
hasattr
(
relationship
,
'all'
))
else
relationship
def
to_representation
(
self
,
iterable
):
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