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
1d2fba90
Commit
1d2fba90
authored
Jun 29, 2016
by
Vikalp Jain
Committed by
Tom Christie
Jun 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issues with routers for custom list-route and detail-routes (#4229)
parent
d41ddc9e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletions
+4
-1
rest_framework/routers.py
+4
-1
No files found.
rest_framework/routers.py
View file @
1d2fba90
...
@@ -144,7 +144,9 @@ class SimpleRouter(BaseRouter):
...
@@ -144,7 +144,9 @@ class SimpleRouter(BaseRouter):
Returns a list of the Route namedtuple.
Returns a list of the Route namedtuple.
"""
"""
known_actions
=
flatten
([
route
.
mapping
.
values
()
for
route
in
self
.
routes
if
isinstance
(
route
,
Route
)])
# converting to list as iterables are good for one pass, known host needs to be checked again and again for
# different functions.
known_actions
=
list
(
flatten
([
route
.
mapping
.
values
()
for
route
in
self
.
routes
if
isinstance
(
route
,
Route
)]))
# Determine any `@detail_route` or `@list_route` decorated methods on the viewset
# Determine any `@detail_route` or `@list_route` decorated methods on the viewset
detail_routes
=
[]
detail_routes
=
[]
...
@@ -154,6 +156,7 @@ class SimpleRouter(BaseRouter):
...
@@ -154,6 +156,7 @@ class SimpleRouter(BaseRouter):
httpmethods
=
getattr
(
attr
,
'bind_to_methods'
,
None
)
httpmethods
=
getattr
(
attr
,
'bind_to_methods'
,
None
)
detail
=
getattr
(
attr
,
'detail'
,
True
)
detail
=
getattr
(
attr
,
'detail'
,
True
)
if
httpmethods
:
if
httpmethods
:
# checking method names against the known actions list
if
methodname
in
known_actions
:
if
methodname
in
known_actions
:
raise
ImproperlyConfigured
(
'Cannot use @detail_route or @list_route '
raise
ImproperlyConfigured
(
'Cannot use @detail_route or @list_route '
'decorators on method "
%
s" '
'decorators on method "
%
s" '
...
...
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