Commit 005f475c by Tom Christie

Don't consume .json style suffixes with routers.

When trailing slash is false, the lookup regex should not consume '.'
characters.  Fixes #1057.
parent f54fc3a7
...@@ -189,7 +189,11 @@ class SimpleRouter(BaseRouter): ...@@ -189,7 +189,11 @@ class SimpleRouter(BaseRouter):
Given a viewset, return the portion of URL regex that is used Given a viewset, return the portion of URL regex that is used
to match against a single instance. to match against a single instance.
""" """
base_regex = '(?P<{lookup_field}>[^/]+)' if self.trailing_slash:
base_regex = '(?P<{lookup_field}>[^/]+)'
else:
# Don't consume `.json` style suffixes
base_regex = '(?P<{lookup_field}>[^/.]+)'
lookup_field = getattr(viewset, 'lookup_field', 'pk') lookup_field = getattr(viewset, 'lookup_field', 'pk')
return base_regex.format(lookup_field=lookup_field) return base_regex.format(lookup_field=lookup_field)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment