From 80dedd66e8c9c8076b9a70716f640c746f05d678 Mon Sep 17 00:00:00 2001 From: Vikalp Jain Date: Wed, 29 Jun 2016 16:57:02 +0530 Subject: [PATCH] Fix issues with routers for custom list-route and detail-routes --- rest_framework/routers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 027a78cc13..70a1149ab4 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -144,7 +144,9 @@ def get_routes(self, viewset): Returns a list of the Route namedtuple. """ - known_actions = flatten([route.mapping.values() for route in self.routes if isinstance(route, Route)]) + # converting to list as iterables are good for one pass, known host needs to be checked again and again for + # different functions. + known_actions = list(flatten([route.mapping.values() for route in self.routes if isinstance(route, Route)])) # Determine any `@detail_route` or `@list_route` decorated methods on the viewset detail_routes = [] @@ -154,6 +156,7 @@ def get_routes(self, viewset): httpmethods = getattr(attr, 'bind_to_methods', None) detail = getattr(attr, 'detail', True) if httpmethods: + # checking method names against the known actions list if methodname in known_actions: raise ImproperlyConfigured('Cannot use @detail_route or @list_route ' 'decorators on method "%s" ' pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy