HttpResponseRedirectView - Redirect to a view

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse

class HttpResponseRedirectView(HttpResponseRedirect):
    """
        This response directs to a view by reversing the url
    
        e.g. return HttpResponseRedirectView('org.myself.views.myview') 
        or use the view object e.g.
             from org.myself.views import myview
             return HttpResponseRedirectView(myview)
        
        You can also pass the url arguments to the constructor e.g.
        return HttpResponseRedirectView('org.myself.views.myview', year=2008, colour='orange')
    """
    def __init__(self, view, *args, **kwargs):
        viewurl = reverse(view, args=args, kwargs=kwargs)
        HttpResponseRedirect.__init__(self, viewurl)

More like this

  1. activation_required by offline 4 years, 11 months ago
  2. Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
  3. Caching XHTML render_to_response by smoonen 4 years, 10 months ago
  4. Generic object_detail view with multiple named URL filters by cotton 1 year, 5 months ago
  5. Using reverse() to do redirects by ubernostrum 5 years, 9 months ago

Comments

km0r3 (on October 29, 2010):

There's django.shortcuts.redirect in Django 1.2, which I recommend.

#

(Forgotten your password?)