I have a functioning datepicker on my django app called tempus dominus. I am having some trouble trying to set this datepicker to submit without having to click on a submit button.
Their documentation is horrible but I finally figured at least part of it, it seems that I have to trigger one of their custom events (change.datetimepicker). Below you will find my implementation... My js skills are quite rusty so probably the problem lies somewhere there...
my forms.py
class MyForm(forms.Form):
date_from = forms.DateField(
required=True,
widget=DatePicker(
options={
'minDate': '2018-01-20',
'maxDate': '2020-10-20',
},
),
initial='2020-08-01',
)
date_to = forms.DateField(
required=True,
widget=DatePicker(
options={
'minDate': '2018-01-20',
'maxDate': '2020-10-20',
},
),
initial='2020-10-19',
)
my template
<div class="col" id="form_div">
<form method="post" action="." id="datetimepicker" class="form-inline justify-content-center">
{% csrf_token %}
{{ form.as_p}}
<input type="submit" id="submit" value="enviar" style="width:70px" />
</form>
</div>
my js file
$("#datetimepicker").on("change.datetimepicker", function () {
$( "#datetimepicker" ).submit();
});
Any help is appreciated!