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
- Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
- Generic object_detail view filterable by multiple url values by jlorich 2 years ago
- Yet another query string template tag by atms 2 years, 1 month ago
- Persistent Params Decorator by achimnol 3 years, 9 months ago
- Add GET parameters from current request by naktinis 2 years ago
Comments
This is now supported in Django 1.3 out of the box.
#