[Fixed]-Best Practice to handle form submission status pages reload

1👍

The messages displayed using the Django messages framework are displayed once in the subsequent request. If you refresh the page or go to another page, the message will disappear. This is the intended behaviour of using messages.

As per Django messaging framework docs:

Quite commonly in web applications, you need to display a one-time
notification message (also known as “flash message”) to the user after
processing a form or some other types of user input.

The messages framework allows you to temporarily store messages in one
request and retrieve them for display in a subsequent request (usually
the next one).

To solve your issue, you can send the success or failure as a parameter in the url parameters and then display the message in the template according to its value. Then, when the user refreshes the page, the message text will still be displayed in the template.

Leave a comment