I want to use the bootstrap-datepicker (https://bootstrap-datepicker.readthedocs.org) in my django application. I use Django 1.7.
In index.html file I have:
<link rel="stylesheet" href="{% static 'my_app/css/bootstrap-theme.min.css' %}">
<link rel="stylesheet" href="{% static 'my_app/css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'my_app/js/bootstrap-datepicker.js' %}">
<link rel="stylesheet" href="{% static 'my_app/css/datepicker.css' %}">
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
$(document).ready(function(){
$('.datepicker').datepicker();
});
</script>
In my forms.py I have:
class Filter(django_filters.FilterSet):
class Meta:
model = MyModel
fields = ['user', 'date_from', 'date_to']
widgets = {'date': forms.DateInput(attrs={'class':'datepicker'})}
I my model.py I use to set date:
date_from = models.DateField()
date_to = models.DateField()
When I'm going through the page with the date - does not work in input area.
See Question&Answers more detail:os