1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | class Redirect(Exception):
def __init__(self, url):
self.url = url
# where request is not:
raise Redirect(reverse('someurl'))
# redirect handler, where request is:
from django.http import HttpResponseRedirect
try:
return something(request, ...)
except Redirect, r:
return HttpResponseRedirect(r.url)
|
More like this
- Redirect with change list with filters intact with admin actions by AndrewIngram 3 years, 10 months ago
- Simple Exception Response for AJAX debugging by newmaniese 5 years, 2 months ago
- Quick script to convert json data to csv by stephenemslie 3 years ago
- Message exception by marinho 4 years, 7 months ago
- Middleware to prevent access to the admin when user ip not in INTERNAL_IPS by jezdez 2 years, 10 months ago
Comments