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
0ad017a5
Commit
0ad017a5
authored
May 29, 2017
by
이동환
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
requested changes
parent
973860d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
rest_framework/routers.py
+5
-2
No files found.
rest_framework/routers.py
View file @
0ad017a5
...
@@ -35,7 +35,10 @@ DynamicDetailRoute = namedtuple('DynamicDetailRoute', ['url', 'name', 'initkwarg
...
@@ -35,7 +35,10 @@ DynamicDetailRoute = namedtuple('DynamicDetailRoute', ['url', 'name', 'initkwarg
DynamicListRoute
=
namedtuple
(
'DynamicListRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
DynamicListRoute
=
namedtuple
(
'DynamicListRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
def
replace_curly_brackets
(
url_path
):
def
escape_curly_brackets
(
url_path
):
"""
Double brackets in regex of url_path for escape string formatting
"""
if
(
'{'
and
'}'
)
in
url_path
:
if
(
'{'
and
'}'
)
in
url_path
:
url_path
=
url_path
.
replace
(
'{'
,
'{{'
)
.
replace
(
'}'
,
'}}'
)
url_path
=
url_path
.
replace
(
'{'
,
'{{'
)
.
replace
(
'}'
,
'}}'
)
return
url_path
return
url_path
...
@@ -184,7 +187,7 @@ class SimpleRouter(BaseRouter):
...
@@ -184,7 +187,7 @@ class SimpleRouter(BaseRouter):
initkwargs
=
route
.
initkwargs
.
copy
()
initkwargs
=
route
.
initkwargs
.
copy
()
initkwargs
.
update
(
method_kwargs
)
initkwargs
.
update
(
method_kwargs
)
url_path
=
initkwargs
.
pop
(
"url_path"
,
None
)
or
methodname
url_path
=
initkwargs
.
pop
(
"url_path"
,
None
)
or
methodname
url_path
=
replac
e_curly_brackets
(
url_path
)
url_path
=
escap
e_curly_brackets
(
url_path
)
url_name
=
initkwargs
.
pop
(
"url_name"
,
None
)
or
url_path
url_name
=
initkwargs
.
pop
(
"url_name"
,
None
)
or
url_path
ret
.
append
(
Route
(
ret
.
append
(
Route
(
url
=
replace_methodname
(
route
.
url
,
url_path
),
url
=
replace_methodname
(
route
.
url
,
url_path
),
...
...
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