Rajeshwar Rajeshwar - 10 months ago 53
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 ?


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! ;)