When a model form is saved, it validates the form if it hasn’t already been validated. (See the save method and Form.errors)
You’ve got a couple ways to work around this:
-
Create two forms - one with the fields being required as necessary and one without. This second form would also be saving the form to a model that allows all fields to be null. Perform the test for which button was pressed before binding the post data to the form, and bind the appropriate form after checking the button.
-
Alter the
__init__
method of the form to allow a parameter to be passed to identify whether or not fields are to be required. Change your binding call to pass that parameter accordingly. -
Create two separate views that the different buttons would submit to and handle the responses appropriately. (See <input type="submit"> - HTML: HyperText Markup Language | MDN)
I’m sure there are other options - these are just some of the ideas that come to mind.