1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from django.http import HttpResponseGone, HttpResponsePermanentRedirect,\
HttpResponseRedirect
def redirect_to(request, url, permanent=True, **kwargs):
if url is not None:
klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect
url = url % kwargs
if request.GET:
url = '?'.join([url, request.META['QUERY_STRING']])
return klass(url)
return HttpResponseGone()
|
More like this
- Persistent Params Decorator by achimnol 2 years, 6 months ago
- login_required decorator that doesn't redirect by brutasse 11 months, 4 weeks ago
- Redirect view based on GEO by jorjun 2 years, 6 months ago
- login_required for a generic view in URLconf by pgugged 3 years, 7 months ago
- django redirects middleware a bit more fleixble by robertrv 2 years, 3 months ago
Comments
This is now supported in Django 1.3 out of the box.
#