[Answered ]-Django, "render" returns a POST request and not GET after a POST request

1👍

render simply renders the template, and wraps this in a HttpResponse and returns that as response to the HTTP request, regardless what that request is.

This means that if the form is valid, and you render a response back, then refreshing will normally make the same HTTP request. This thus means that a person who makes an order can for example make a second order by just refreshing the webpage.

As a result in case of a successful request (so where the form is valid), one implements the Post/Redirect/Get architectural pattern [wiki]. In that case, it does not render a template, but it returns a redirect response (a response with status code 302), and thus asks the browser to make a GET request to the passed url.

You can make such redirect with the redirect(…) function [Django-doc].

Leave a comment