diff --git a/django/middleware/common.py b/django/middleware/common.py index a564017ed6..270ab995bb 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -54,7 +54,7 @@ class CommonMiddleware(object): # trailing slash and there is no pattern for the current path if settings.APPEND_SLASH and (not old_url[1].endswith('/')): try: - urlresolvers.resolve(request.path) + urlresolvers.resolve(request.path_info) except urlresolvers.Resolver404: new_url[1] = new_url[1] + '/' if settings.DEBUG and request.method == 'POST': @@ -69,7 +69,7 @@ class CommonMiddleware(object): if new_url != old_url: # Redirect if the target url exists try: - urlresolvers.resolve(new_url[1]) + urlresolvers.resolve("%s/" % request.path_info) except urlresolvers.Resolver404: pass else: diff --git a/tests/regressiontests/middleware/tests.py b/tests/regressiontests/middleware/tests.py index 5e7fd320d6..3252971253 100644 --- a/tests/regressiontests/middleware/tests.py +++ b/tests/regressiontests/middleware/tests.py @@ -12,7 +12,7 @@ class CommonMiddlewareTest(TestCase): 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } - request.path = "/middleware/%s" % path + request.path = request.path_info = "/middleware/%s" % path return request def test_append_slash_have_slash(self):