title: Django template variables from {% for %} loop into Javascript
body: <p>This is a Django template iterating through records. Each record contains a div that JS function fills in. In order for JS to know what to do, it needs to get a variable from each for loop iteration and use it. I don't know exactly how to achieve that or if it's possible. Maybe a different approach is needed where ever record triggers a timer in a separate JS object instance, I don't know.</p>
  
  <p>---------- html -----------------------</p>
  
  <pre><code>{% for match in upcoming_matches %}
  ...
  
  &lt;tr&gt;
  &lt;td&gt; Match title &lt;/td&gt;
  &lt;td&gt; Match time &lt;/td&gt;
  &lt;td&gt; Starts in: &lt;/td&gt;
  &lt;tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; {{ match.title }} &lt;/td&gt;
  &lt;td&gt; {{ match.start_time }} &lt;/td&gt;
  &lt;td&gt; &lt;div id="matchCountdown"/&gt;&lt;/td&gt;
  &lt;tr&gt;
  
  ...
  
  {% endfor %}
  </code></pre>
  
  <p>------------ JS ---------------------------</p>
  
  <pre><code>$(function () {
  
          var start_date = {{ match.start_date }}; // Obviously I can't access vars from for loop, I could access upcoming_matches but not the ones from for loop
  
  
          var matchDate = new Date(start_date.getTime() 
  
       $('#matchCountdown').countdown({until: matchDate});
  
      });
  </code></pre>