Pass through remaining query arguments.

- Legacy-Id: 342
This commit is contained in:
Bill Fenner 2007-06-12 18:50:41 +00:00
parent 890b8a1ada
commit 0d2bbe54e9

View file

@ -33,4 +33,11 @@ def redirect(request, path="", script=""):
url = re.sub(r'/+', '/', url)
if remove:
url = re.sub(re.escape(remove) + "/?$", "", url)
# Copy the GET arguments, remove all the ones we were
# expecting and if there are any left, add them to the URL.
get = request.GET.copy()
for arg in re.findall(r'%\(([^)]+)\)', rest):
get.pop(arg)
if get:
url += '?' + get.urlencode()
return HttpResponseRedirect(url)