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
d972df7c
Commit
d972df7c
authored
Nov 03, 2014
by
tanwanirahul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ability to override default method names by customizing it
parent
96bb77dc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
rest_framework/routers.py
+10
-6
No files found.
rest_framework/routers.py
View file @
d972df7c
...
@@ -176,23 +176,27 @@ class SimpleRouter(BaseRouter):
...
@@ -176,23 +176,27 @@ class SimpleRouter(BaseRouter):
if
isinstance
(
route
,
DynamicDetailRoute
):
if
isinstance
(
route
,
DynamicDetailRoute
):
# Dynamic detail routes (@detail_route decorator)
# Dynamic detail routes (@detail_route decorator)
for
httpmethods
,
methodname
in
detail_routes
:
for
httpmethods
,
methodname
in
detail_routes
:
method_kwargs
=
getattr
(
viewset
,
methodname
)
.
kwargs
custom_method_name
=
method_kwargs
.
pop
(
"custom_method_name"
,
None
)
or
methodname
initkwargs
=
route
.
initkwargs
.
copy
()
initkwargs
=
route
.
initkwargs
.
copy
()
initkwargs
.
update
(
getattr
(
viewset
,
methodname
)
.
kwargs
)
initkwargs
.
update
(
method_
kwargs
)
ret
.
append
(
Route
(
ret
.
append
(
Route
(
url
=
replace_methodname
(
route
.
url
,
method
name
),
url
=
replace_methodname
(
route
.
url
,
custom_method_
name
),
mapping
=
dict
((
httpmethod
,
methodname
)
for
httpmethod
in
httpmethods
),
mapping
=
dict
((
httpmethod
,
methodname
)
for
httpmethod
in
httpmethods
),
name
=
replace_methodname
(
route
.
name
,
method
name
),
name
=
replace_methodname
(
route
.
name
,
custom_method_
name
),
initkwargs
=
initkwargs
,
initkwargs
=
initkwargs
,
))
))
elif
isinstance
(
route
,
DynamicListRoute
):
elif
isinstance
(
route
,
DynamicListRoute
):
# Dynamic list routes (@list_route decorator)
# Dynamic list routes (@list_route decorator)
for
httpmethods
,
methodname
in
list_routes
:
for
httpmethods
,
methodname
in
list_routes
:
method_kwargs
=
getattr
(
viewset
,
methodname
)
.
kwargs
custom_method_name
=
method_kwargs
.
pop
(
"custom_method_name"
,
None
)
or
methodname
initkwargs
=
route
.
initkwargs
.
copy
()
initkwargs
=
route
.
initkwargs
.
copy
()
initkwargs
.
update
(
getattr
(
viewset
,
methodname
)
.
kwargs
)
initkwargs
.
update
(
method_
kwargs
)
ret
.
append
(
Route
(
ret
.
append
(
Route
(
url
=
replace_methodname
(
route
.
url
,
method
name
),
url
=
replace_methodname
(
route
.
url
,
custom_method_
name
),
mapping
=
dict
((
httpmethod
,
methodname
)
for
httpmethod
in
httpmethods
),
mapping
=
dict
((
httpmethod
,
methodname
)
for
httpmethod
in
httpmethods
),
name
=
replace_methodname
(
route
.
name
,
method
name
),
name
=
replace_methodname
(
route
.
name
,
custom_method_
name
),
initkwargs
=
initkwargs
,
initkwargs
=
initkwargs
,
))
))
else
:
else
:
...
...
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