If you manually write HTML for submit buttons, you can add an attribute nameand valuethat your Django application can use:
<button name="action" value="save">Save</button>
<button name="action" value="submit">Submit</button>
When the form is submitted, you can find out what action the user should perform.
class MyForm(forms.Form):
def __init__(self, data=None, *args, **kwargs):
super(MyForm, self).__init__(data=data, *args, **kwargs)
self.action = data.get('action') if data else None
if self.action == 'save':
for field in self.fields:
field.required = False
source
share