diff options
| author | Tom Christie | 2013-08-23 14:58:06 +0100 | 
|---|---|---|
| committer | Tom Christie | 2013-08-23 14:58:06 +0100 | 
| commit | 005f475c6af023cc7c75cf38d3a89e22638e5d84 (patch) | |
| tree | b3be3f4b664eafe24053c020995796f936066c5a /rest_framework/routers.py | |
| parent | f54fc3a76bdb872eb3b0ba562db08e3fd7c879af (diff) | |
| download | django-rest-framework-005f475c6af023cc7c75cf38d3a89e22638e5d84.tar.bz2 | |
Don't consume .json style suffixes with routers.
When trailing slash is false, the lookup regex should not consume '.'
characters.  Fixes #1057.
Diffstat (limited to 'rest_framework/routers.py')
| -rw-r--r-- | rest_framework/routers.py | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 930011d3..3fee1e49 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -189,7 +189,11 @@ class SimpleRouter(BaseRouter):          Given a viewset, return the portion of URL regex that is used          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')          return base_regex.format(lookup_field=lookup_field) | 
