@@ -64,18 +64,6 @@ def escape_curly_brackets(url_path):
64
64
return url_path
65
65
66
66
67
- def replace_methodname (format_string , methodname ):
68
- """
69
- Partially format a format_string, swapping out any
70
- '{methodname}' or '{methodnamehyphen}' components.
71
- """
72
- methodnamehyphen = methodname .replace ('_' , '-' )
73
- ret = format_string
74
- ret = ret .replace ('{methodname}' , methodname )
75
- ret = ret .replace ('{methodnamehyphen}' , methodnamehyphen )
76
- return ret
77
-
78
-
79
67
def flatten (list_of_lists ):
80
68
"""
81
69
Takes an iterable of iterables, returns a single iterable containing all items
@@ -130,8 +118,8 @@ class SimpleRouter(BaseRouter):
130
118
# Generated using @list_route decorator
131
119
# on methods of the viewset.
132
120
DynamicRoute (
133
- url = r'^{prefix}/{methodname }{trailing_slash}$' ,
134
- name = '{basename}-{methodnamehyphen }' ,
121
+ url = r'^{prefix}/{url_path }{trailing_slash}$' ,
122
+ name = '{basename}-{url_name }' ,
135
123
detail = False ,
136
124
initkwargs = {}
137
125
),
@@ -151,8 +139,8 @@ class SimpleRouter(BaseRouter):
151
139
# Dynamically generated detail routes.
152
140
# Generated using @detail_route decorator on methods of the viewset.
153
141
DynamicRoute (
154
- url = r'^{prefix}/{lookup}/{methodname }{trailing_slash}$' ,
155
- name = '{basename}-{methodnamehyphen }' ,
142
+ url = r'^{prefix}/{lookup}/{url_path }{trailing_slash}$' ,
143
+ name = '{basename}-{url_name }' ,
156
144
detail = True ,
157
145
initkwargs = {}
158
146
),
@@ -219,10 +207,10 @@ def _get_dynamic_route(self, route, action):
219
207
url_path = escape_curly_brackets (action .url_path )
220
208
221
209
return Route (
222
- url = replace_methodname ( route .url , url_path ),
210
+ url = route .url . replace ( '{url_path}' , url_path ),
223
211
mapping = {http_method : action .__name__
224
212
for http_method in action .bind_to_methods },
225
- name = replace_methodname ( route .name , action .url_name ),
213
+ name = route .name . replace ( '{url_name}' , action .url_name ),
226
214
detail = route .detail ,
227
215
initkwargs = initkwargs ,
228
216
)
0 commit comments