I have a view that displays a form. Now, depending on which button the user selects, I want the data to be processed differently. These "different ways" correspond to the different views I want the POST request to go to.
Please help me build a form with multiple buttons that lead to different urls/views.
<form action="/your-name/" method="post"> {% csrf_token %} {{ form }} <input type="submit" value="Process form with view ONE"> <input type="submit" value="Process form with view TWO"> <input type="submit" value="Process form with view THREE"> </form>
My problem is that the action attribute of the form tag defines where this POST request goes. How to change destination url with multiple buttons?
I know I can handle this logic on the server side as well. But the question is: Do Imust? If not, please show me the way
You can use ajax via the
onclick
attribute.post_url
As such a parameter