File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,9 @@ def get_routes(self, viewset):
144
144
145
145
Returns a list of the Route namedtuple.
146
146
"""
147
- known_actions = flatten ([route .mapping .values () for route in self .routes if isinstance (route , Route )])
147
+ # converting to list as iterables are good for one pass, known host needs to be checked again and again for
148
+ # different functions.
149
+ known_actions = list (flatten ([route .mapping .values () for route in self .routes if isinstance (route , Route )]))
148
150
149
151
# Determine any `@detail_route` or `@list_route` decorated methods on the viewset
150
152
detail_routes = []
@@ -154,6 +156,7 @@ def get_routes(self, viewset):
154
156
httpmethods = getattr (attr , 'bind_to_methods' , None )
155
157
detail = getattr (attr , 'detail' , True )
156
158
if httpmethods :
159
+ # checking method names against the known actions list
157
160
if methodname in known_actions :
158
161
raise ImproperlyConfigured ('Cannot use @detail_route or @list_route '
159
162
'decorators on method "%s" '
You can’t perform that action at this time.
0 commit comments