mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Simpler 'get_lookup_prefix' change
This commit is contained in:
parent
2bec7e6d8c
commit
18bb6bcf0c
|
@ -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__
|
||||
|
|
Loading…
Reference in New Issue
Block a user