1👍
-
The view can be sure that the form is validated because it will only be called if the form is valid…
-
If the page is generated through a post request the browser will always ask you that when hitting refresh… I guess the only way to avoid this would be redirecting to another page!
1👍
How can the view in “/thanks/” be sure that the form was validated?
form.is_valid()
should thoroughly check any field or – if necessary – any combination, cornercase, etc. That’s basically it. The views knows, the form was valid if it renders. There is no need to include redundant information in the session.
How can one write this code in a way that when form is NOT valid and the page is shown with errors upon submission, if user refreshes the browser it wouldn’t ask the user if they want to POST data again?
I am not sure what the point would be. The form contains errors and the user may correct them or leave. To render a page that would not ask for form resubmission, one could use a redirect, just as in the valid case. The error markup would have to be done manually in that case.
- [Answered ]-Django/Ajax Get "data" returning html from firing page instead of target view
- [Answered ]-CSS GET returns 404
- [Answered ]-Django Multiple db with read only
- [Answered ]-Django filtering by a value which might be in a many-to-many field