title: Pass python/django variable into javascript as JSON?
body: <p>Woking on personal project website with django 1.9 and python 3.4. I am using <a href="http://fullcalendar.io" rel="nofollow noreferrer">FullCalendar</a>. The idea is to pass a set of appointment objects into the html page containing the javascript for the calendar. But right now, I am just trying to pass a single default appointment.</p>
  
  <p>In <strong>views.py</strong> I have the following:</p>
  
  <pre><code>appt = json.dumps({ "title": "meeting", "start": "2016-11-20"});
  return render(request, 'healthnet/profile_patient.html', {'patient': patient, 'appt': appt_set})
  </code></pre>
  
  <p>In <strong>profile_patient.html</strong>:</p>
  
  <pre><code>&lt;script&gt;
  
      var data = jQuery.parseJSON("{{appt}}");
  
      var events;
      events = [];
      events.push(data);
  
  
      $(document).ready(function() {
  
          $('#calendar').fullCalendar({
              editable: true,
              eventLimit: true, // allow "more" link when too many events
              events: events
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><code>appt</code> is not getting properly parsed I believe. When the web page is loaded, the calendar does not display at all. </p>
  
  <p>When I substitute <code>appt</code> with the direct string, it does work:</p>
  
  <pre><code>var data = jQuery.parseJSON('{"title": "meeting", "start": "2016-11-20"}');
  </code></pre>
  
  <p>When I call <code>alert("{{appt}}");</code> i get the following:</p>
  
  <p><img src="https://i.stack.imgur.com/jwSAb.png" alt="enter image description here"></p>
  
  <p>So there's something wrong with the way I'm using ths varibale. Any ideas?</p>