I want to implement a django form with datepicker. I made my forms.py
from django import forms
class DateRangeForm(forms.Form):
start_date = forms.DateField(widget=forms.TextInput(attrs=
{
'class':'datepicker'
}))
end_date = forms.DateField(widget=forms.TextInput(attrs=
{
'class':'datepicker'
}))
and
views.py
if request.method == "POST":
f = DateRangeForm(request.POST)
if f.is_valid():
c = f.save(commit = False)
c.end_date = timezone.now()
c.save()
else:
f = DateRangeForm()
args = {}
args.update(csrf(request))
args['form'] = f
return render(request, 'trial_balance.html', {
'form': f
})
balance.html
<div>
<form action="" method="POST"> {% csrf_token %}
Start Date:{{ form.start_date }} End Date:{{ form.end_date }}<br/>
<input type = "submit" name = "submit" value = "See Results">
</form>
</div>
And still there is no datepicker in my input box of that form.
I also tried with including my files link in the script as in my balance.html
<script src="{{ STATIC_URL }}js/jquery-1.3.2.min.js"></script>
still the datepicker is not working. But when including jquery in my html file, it also makes not to work jquery-treetable which I have implemented in my html file.
How to make the datepicker work ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…