0
Good afternoon, I’m working on a project to book rooms using Django and fullcalendar. It turns out that the end date of the selected period is not recorded in the calendar. The record stops the day before the end date. I have seen that this is standard fullcalendar and I must make the system understand that the end date is the day after the 00:00
. I also saw the possibility of using the add
of momentjs. In addition I tried to solve by python using the datetime library but I could not solve. Dates are entered by datepicker. From now on I thank anyone who can help me.
html script of the page that receives the dates
<script>
var today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate());
$('#{{ form.start_date.id_for_label }}').datepicker({
uiLibrary: 'bootstrap4',
format: 'dd/mm/yyyy',
minDate: today,
maxDate: function () {
return $('#{{ form.end_date.id_for_label }}').val();
}
});
$('#{{ form.end_date.id_for_label }}').datepicker({
uiLibrary: 'bootstrap4',
format: 'dd/mm/yyyy',
minDate: function () {
return $('#{{ form.start_date.id_for_label }}').val();
}
});
</script>
html script of the calendar template:
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
locale: 'pt-br',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay',
},
events: [
{% for reserva in reservas %}
{
title : '{{ reserva.name }}',
start : '{{ reserva.start_date|date:'Y-m-d' }}',
end : '{{ reserva.end_date|date:'Y-m-d' }}',
color: '{{ reserva.quarto.color|default:'darkblue' }}',
url: '{% url 'api:reserva-list' %}{{ reserva.id }}',
allDayDefault : true,
{% if reserva.status == 'canceled' %}
borderColor: 'red',
textColor: 'darkred',
{% else %}
borderColor: 'black',
{% endif %}
},
{% endfor %}
]
})
});
</script>