The basic implementation of the Bootstrap Datepicker works correctly, what does not work is the datesDisabled
(deactivate dates):
My forms.py:
class BookForm(forms.ModelForm):
class Meta:
dateTimeOptions = {
'format': 'dd/mm/yyyy',
'autoclose': True,
'startDate': datetime.now().strftime("%d/%m/%Y"),
'datesDisabled': ['20/02/2017']
}
model = Reserva
fields = ['fecha_entrada','fecha_salida']
widgets = {
'fecha_entrada': DateWidget(attrs={'id':"start",'readonly':'readonly','class':'datepicker'}, usel10n = True, bootstrap_version=3, options = dateTimeOptions),
'fecha_salida': DateWidget(attrs={'id':"end",'readonly':'readonly','class':'datepicker'}, usel10n = True, bootstrap_version=3, options = dateTimeOptions)
}
Basically what this form does is insert a script
for each input so that:
<script type="text/javascript">
$("#start").datetimepicker({format: 'dd/mm/yyyy',
autoclose: true,
startDate: '28/01/2017',
startView: 2,
minView: 2,
language: 'es'}).find('input').addClass("form-control");
</script>
This script
is what requires Bootstrap
in .html
for its operation. The problem arises when I insert the datesDisabled: ['20/02/2017']
for example, as put the Bootstrap documentation and it seems that he does not care, no kind of error, he just does not read it. I have latest version of Bootstrap, JavaScript and jQuery.