Hello I have this js script data is coming from django I am using PDFTemplate to generate the html below. Code works properly on hardcoded dates but when I tried to make dynamic dates via object.created the result pdf shows nothing or dates are not properly position where it should be, say I chose Monday but it is saved as date today(Friday).
{% load i18n humanize %}
{% load dashboard_tags %}
{% load static from staticfiles %}
<!DOCTYPE html>
<html>
<head>
<link href="https://db.onlinewebfonts.com/c/7c6661efce01eac269383bac79303c1b?family=Arial+Narrow" rel="stylesheet" type="text/css"/>
<link rel='stylesheet' type='text/css' href='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.css' />
<script src='http://fullcalendar.io/js/fullcalendar-2.1.1/lib/moment.min.js'></script>
<script src='http://fullcalendar.io/js/fullcalendar-2.1.1/lib/jquery.min.js'></script>
<script src="http://fullcalendar.io/js/fullcalendar-2.1.1/lib/jquery-ui.custom.min.js"></script>
<script src='http://fullcalendar.io/js/fullcalendar-2.1.1/fullcalendar.min.js'></script>
<style>
body {
margin: 0;
padding: 0;
font-family: "Arial Narrow";
font-size: 12pt;
}
.center {
margin: auto;
text-align: center;
}
.fc-today
{
background-color:inherit !important;
}
</style>
</head>
<body>
<div class="center" style="line-height: 20px">
<h4>CLASS SCHEDULE</h4>
</div>
<br>
<br>
<div id="calendar"></div>
<table style="font-size: 12px; width: 80%" class="center">
<tr>
<td colspan="4" align="left">{{section.get_term_display|title}}</td>
</tr>
{% for subsched in schedules %}
{% for sched in subsched.scheduling_set.all %}
<tr>
<td>{{ subsched.subject.code }}</td>
<td align="left">{{ subsched.subject.name|title }}</td>
<td>{{ subsched.subject.units }}</td>
</tr>
{% endfor %}
{% endfor %}
</table>
</body>
<script>
$(document).ready(function() {
$(function() {
$('#calendar').fullCalendar({
defaultView: "agendaWeek",
defaultDate: "2019-04-19",
slotDuration:"00:30:00",
allDaySlot: false,
columnFormat: "ddd",
header: false,
minTime: "7:00:00",
maxTime: "20:00:00",
editable: true,
selectable: true,
eventOverlap: false,
header: {
left: "",
center: "",
right: "",
},
events: [
{% for subsched in schedules %}
{% for sched in subsched.scheduling_set.all %}
{
title: '{{subsched.subject.code}} ({{sched.schedule_type|title|slice:"3"}})',
{% if sched.day|slugify == '0' %}
start: (
'2019-04-14 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-14 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '1' %}
start: (
'2019-04-15 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-15 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '2' %}
start: (
'2019-04-16 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-16 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '3' %}
start: (
'2019-04-17 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-17 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '4' %}
start: (
'2019-04-18 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-18 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '5' %}
start: (
'2019-04-19 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-19 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '6' %}
start: (
'2019-04-20 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-20 {{sched.time_to|date:"H:i:s"}}'
),
{% elif sched.day|slugify == '7' %}
start: (
'2019-04-21 {{sched.time_from|date:"H:i:s"}}'
),
end: (
'2019-04-21 {{sched.time_to|date:"H:i:s"}}'
),
{% endif %}
},
{% endfor %}
{% endfor %}
],
});
});
});
</script>
</html>
This is the result of pdf on hard coded and when I remove the hard coded dates the blue disappear.
full calendar where I save the schedule works well but not when I generate the pdf