Hi Nirantar,
On 09/05/2020 15.15, Nirantar Kulkarni wrote:
>
> I have multiple submit buttons for same form and each button refreshes
> the page
> I don't want it to refresh as it removes all changes made by one button
> to perform changes made by another please help me
>
As far as I know, you can only have one action with a plain HTML form.
It might be possible to have more than one submit button, but I don't
think that's part of the standard and might be handled differently
depending on the browser.
If you don't mind the refreshing as long as the data is still there, you
can prefill the form with the contents submitted. That is all easily
handled with standard Django.
You probably need some javascript magic to handle multiple submits though.
I would try something like hiding the actual submit button from the form
and then adding different buttons outside of the form and write some
javascript handler that would submit the form with an extra field
depending on which button was pressed. You could also make the same
javascript action send the data directly to avoid refreshing of the page.
In short, I'm fairly certain you cannot achieve what you want without
writing some kind of client-side javascript :-(
Kind regards,
Kasper Laudrup