[Answered ]-Error while redirecting one page to other in django

1👍

To redirect to another page in Django with parameters use this

return HttpResponseRedirect(reverse(viewname='the view to which it should redirect', args=(parameters to be passed)))

0👍

Use redirect, it’s easier than invoking reverse and HttpResponseRedirect directly. (Doc)

from django.shortcuts import redirect
...
    return redirect( 'myapp:url_name', urlparam=value, ...)

which is the same as

    return HttpResponseRedirect( 
         reverse( 'myapp:url_name',
         kwargs={ 'urlparam': value, ... } 
    )

Leave a comment