Rajeshwar Rajeshwar - 1 year ago 119
Python Question

HttpResponseRedirect with reverse not passing parameters

In one definition of my view I am doing this

return HttpResponseRedirect(reverse('home'),{"fail":"true"})

then the destination receiving definition in a view does this

def Validate(request):
rslt = request.GET.get("fail", "False") #--->fail is always false

In the above the variable fail is always
. Any suggestions on why I am always getting a false. Why is my new parameter not being passed ?

Answer Source

It it because you are asking for fail from GET but you are not passing anything in GET.

you need:

return HttpResponseRedirect('%s?fail=%s' % (reverse('home'), True))

then you can catch it like:

request.GET.get("fail", False)

dont misuse Booleans! ;)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download