1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.6.x] Fixed #21795 -- Made add_preserved_filters account for url prefixes.

Thanks to trac username honyczek for the report. Refs #6903.

Backport of 4339e9a92d from master
This commit is contained in:
Loic Bistuer
2014-03-28 21:42:58 +07:00
committed by Tim Graham
parent 916f0de74b
commit a5297c1ef4
3 changed files with 40 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ except ImportError:
from django import template
from django.contrib.admin.util import quote
from django.core.urlresolvers import resolve, Resolver404
from django.core.urlresolvers import Resolver404, get_script_prefix, resolve
from django.utils.http import urlencode
register = template.Library()
@@ -33,8 +33,9 @@ def add_preserved_filters(context, url, popup=False):
if opts and preserved_filters:
preserved_filters = dict(parse_qsl(preserved_filters))
match_url = '/%s' % url.partition(get_script_prefix())[2]
try:
match = resolve(url)
match = resolve(match_url)
except Resolver404:
pass
else: