From 18bb6bcf0c3f2eaaa1e705eef1b33ec0da0ecdc7 Mon Sep 17 00:00:00 2001 From: Alan Justino da Silva Date: Mon, 26 Aug 2013 14:40:59 -0300 Subject: [PATCH] Simpler 'get_lookup_prefix' change --- rest_framework/routers.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 2cf3338e9..b48ed4c14 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -189,9 +189,6 @@ class SimpleRouter(BaseRouter): Given a viewset, return the portion of URL regex that is used to match against a single instance. """ - if lookup_prefix: - lookup_prefix += '_' - base_regex = '(?P<{lookup_prefix}{lookup_field}>[^/]+)' lookup_field = getattr(viewset, 'lookup_field', 'pk') return base_regex.format(lookup_field=lookup_field, lookup_prefix=lookup_prefix) @@ -290,7 +287,7 @@ class NestedSimpleRouter(SimpleRouter): raise RuntimeError('parent registered resource not found') nested_routes = [] - nest_prefix = 'nested_%i' % self.nest_count + nest_prefix = 'nested_%i_' % self.nest_count parent_lookup_regex = parent_router.get_lookup_regex(parent_viewset, nest_prefix) for route in self.routes: route_contents = route.__dict__