-1

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. enter image description here

full calendar where I save the schedule works well but not when I generate the pdf

denmg
  • 360
  • 3
  • 12
  • PDF? How does any of this relate to PDF? It's not clear. Please be clear about exactly what you are doing to generate a PDF, and what relationship that has to the code you've shown. – ADyson Jul 23 '20 at 11:24
  • Also, from what you've said, it sounds like the code you've shown is code what works without problems? If so then, how do you expect us to be able to understand the problem with your broken code, when you haven't shown it? Please also show the code that isn't working, and provide a specific example of a date which is wrong, showing what data you provided, what date you are seeing in the result, and what you expected instead. – ADyson Jul 23 '20 at 11:26
  • P.S. If you require further guidance please read [How To Ask](https://stackoverflow.com/help/how-to-ask) from the Help section. – ADyson Jul 23 '20 at 11:26

1 Answers1

0

Hi this question has been fixed by adding higher version of full calendar its now working all schedules are properly printed on the pdf.

denmg
  • 360
  • 3
  • 12