Hello,
how to avoid-repetitive-resending-of-a-form-by-refreshing in django .?
best
This is generally avoided by properly creating your view to perform a redirect upon successful submission of a form. Review the docs at Working with forms | Django documentation | Django
usually django forms are in the form (haha!):
get → post → display
you should be able to do it this way:
get → post → get (hence display).
While this sounds nice, this might have the drawback of making you form unbound on the second get. There might be a clever way to ensure it stays bound, with initial values set to the user’s values (in case of errors, etc).
As a foot note, some browsers (versions? past versions?) have started to move away from the “confirm on re-post” behaviour, and automatically repost the data when a refresh is performed. This is to be double checked obviously – no idea whether that is there to stay, given how quicky browsers change these days.
Actually, it’s more accurate to describe this as:
get → post → redirect, where that redirect results in a new page accessed via GET.
Refreshing that page then performs another get and does not result in an attempt to POST data.
yeah, was referring (clumsily) to the get/post/get pattern. Anyhoo ![]()