- Author:
- marinho
- Posted:
- October 6, 2009
- Language:
- Python
- Version:
- 1.1
- Tags:
- http view generic redirect_to
- Score:
- 0 (after 0 ratings)
This generic view does the same that 'django.views.generic.simple.redirect_to' does but supports request.GET parameters.
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
- "Magic Link" Management Command by webology 3 weeks, 4 days ago
- Closest ORM models to a latitude/longitude point by simonw 3 weeks, 5 days ago
- Log the time taken to execute each DB query by kennyx46 3 weeks, 5 days ago
- django database snippet by ItsRLuo 1 month ago
- Serialize a model instance by chriswedgwood 2 months ago
Comments
This is now supported in Django 1.3 out of the box.
#
Please login first before commenting.