From 9440c86c4a167f560ff5df4cca4b2c391161ffd0 Mon Sep 17 00:00:00 2001 From: Matt Long Date: Mon, 9 Sep 2013 19:57:41 -0700 Subject: [PATCH] Let format suffixes and no-trailing slash work together Swap the order that the new and existing urls are appended in apply_suffix_patterns. This way, if a format is specified in the request, it will be captured as the format kwargs instead of part of the lookup parameter. --- rest_framework/urlpatterns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/urlpatterns.py b/rest_framework/urlpatterns.py index d9143bb4c..f74311ce5 100644 --- a/rest_framework/urlpatterns.py +++ b/rest_framework/urlpatterns.py @@ -25,10 +25,10 @@ def apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required): view = urlpattern._callback or urlpattern._callback_str kwargs = urlpattern.default_args name = urlpattern.name - # Add in both the existing and the new urlpattern + # Add in both the new and the existing urlpattern + ret.append(url(regex, view, kwargs, name)) if not suffix_required: ret.append(urlpattern) - ret.append(url(regex, view, kwargs, name)) return ret