[Fixed]-Django Login POST hangs when i do HttpResponseRedirect (302)


From https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302

The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header. A browser redirects to this page but search engines don’t update their links to the resource (in ‘SEO-speak’, it is said that the ‘link-juice’ is not sent to the new URL).

Even if the specification requires the method (and the body) not to be altered when the redirection is performed, not all user-agents conform here – you can still find this type of bugged software out there. It is therefore recommended to set the 302 code only as a response for GET or HEAD methods and to use 307 Temporary Redirect instead, as the method change is explicitly prohibited in that case.

In the cases where you want the method used to be changed to GET, use 303 See Other instead. This is useful when you want to give a response to a PUT method that is not the uploaded resource but a confirmation message such as: ‘you successfully uploaded XYZ’.

Also can you share the finding after using a supported python 3 version and django 2.2 LTS



basically, that problem refers to that the web page is exposed to circular redirect as if you use a recursion by calling "redirect" statement

This happen to me when I created code that looks like the following:

    if not request.user.is_superuser or role != 'SubAdmin':
        return redirect('accounts:profile', request.user.id)

and that in the pseudo-code says:
return me to the current user profile when the superuser is not in request, knowing that: I don’t in the request as well so that, the web page will be exposed to the redirect "recursion"

Leave a comment