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)