I would like to get your help on my issue. Usually, when I submit a POST request
in Django
with a submit button, I take the button name like this :
<button id="document-button" type="submit" name="UpdateDocument">Submit</button>
And in my view :
if "UpdateDocument" in request.POST:
... do something
But in my code, I need to submit my form with Javascript onchange
method. Hence, I don't have any button to submit my form :
<form id="select-animal-form" action="" method="POST">
{% csrf_token %}
<fieldset>
<legend><span class="name">Select Animal</span></legend>
{{ form.animal_list }}
</fieldset>
</form>
<script>
$('#select-animal-form').on('change', function(){
$(this).submit();
});
</script>
I would like to pick up the submit request.POST
for this form. I wrote this :
if request.POST and not "UpdateDocument" in request.POST:
... do something
But even buttons Next
or Previous
in my pagination are called in this part. I just want to call in this part the submit form.
How I can do that ?
Thank you