is it possible to submit two different forms, with one submit button in django? i have one form called "instrument" and 4 equal forms "config". now i'd like to submit always one config and instrument. e.g. instrument + config 1, and instrument + config 2. and every config have its own submit button.
i have tried it with one button in the config form:
<input onclick="submitForms()" class="btn btn-primary cfg" type="submit" value="Start" >
and call a js function 'onclick':
submitForms = function(){
console.log('ok'); //only for testing
document.forms["firstForm"].submit();
document.forms["secondForm"].submit();
}
this is my method in the views.py:
if request.method == 'POST':
form1 = dataproviderInstrumentForm(request.POST)
form2 = dynamicTimeseriesForm(request.POST)
print(request.POST)
if form1.is_valid() or form2.is_valid():
# do some stuff
else:
form1 = dataproviderInstrumentForm() # an unbound form
form2 = dynamicTimeseriesForm() # an unbound form