@@ -176,23 +176,27 @@ def get_routes(self, viewset):
176
176
if isinstance (route , DynamicDetailRoute ):
177
177
# Dynamic detail routes (@detail_route decorator)
178
178
for httpmethods , methodname in detail_routes :
179
+ method_kwargs = getattr (viewset , methodname ).kwargs
180
+ custom_method_name = method_kwargs .pop ("custom_method_name" , None ) or methodname
179
181
initkwargs = route .initkwargs .copy ()
180
- initkwargs .update (getattr ( viewset , methodname ). kwargs )
182
+ initkwargs .update (method_kwargs )
181
183
ret .append (Route (
182
- url = replace_methodname (route .url , methodname ),
184
+ url = replace_methodname (route .url , custom_method_name ),
183
185
mapping = dict ((httpmethod , methodname ) for httpmethod in httpmethods ),
184
- name = replace_methodname (route .name , methodname ),
186
+ name = replace_methodname (route .name , custom_method_name ),
185
187
initkwargs = initkwargs ,
186
188
))
187
189
elif isinstance (route , DynamicListRoute ):
188
190
# Dynamic list routes (@list_route decorator)
189
191
for httpmethods , methodname in list_routes :
192
+ method_kwargs = getattr (viewset , methodname ).kwargs
193
+ custom_method_name = method_kwargs .pop ("custom_method_name" , None ) or methodname
190
194
initkwargs = route .initkwargs .copy ()
191
- initkwargs .update (getattr ( viewset , methodname ). kwargs )
195
+ initkwargs .update (method_kwargs )
192
196
ret .append (Route (
193
- url = replace_methodname (route .url , methodname ),
197
+ url = replace_methodname (route .url , custom_method_name ),
194
198
mapping = dict ((httpmethod , methodname ) for httpmethod in httpmethods ),
195
- name = replace_methodname (route .name , methodname ),
199
+ name = replace_methodname (route .name , custom_method_name ),
196
200
initkwargs = initkwargs ,
197
201
))
198
202
else :
0 commit comments