title: Getting a list from Django into Javascript as an array
body: <p>I have a python list generated by my views.py in Django, and I would like to pass it to javascript in my HTML template.
  I cannot seem to get it into javscript as an array... I need to evaluate if the list/array contains certain numbers, but it is coming over as a string.</p>
  
  <p>I am passing the list to my HTML template like this:</p>
  
  <pre><code>def get_context_data(self, **kwargs):
      context = super(dashboardView, self).get_context_data(**kwargs)
      mylist = [10,22,33,45]
      context['mylist'] = mylist
      return context
  </code></pre>
  
  <p>When I use: </p>
  
  <pre><code>&lt;h1 id = "list"&gt; {{mylist}}&lt;/h1&gt;
  </code></pre>
  
  <p>it shows up on the browser as 
  it shows up as [10,22,33,45]</p>
  
  <p>Then in my template I am using javascript I have:</p>
  
  <pre><code>var mylist = document.getElementById("list").innerHTML;
  for(i = 0; i &lt; mylist.length; i++){
      console.log(mylist[i])
  };
  </code></pre>
  
  <p>this returns in the console:</p>
  
  <pre><code>'
  [
  1
  0
  ,
  
  2
  2
  ........
  </code></pre>
  
  <p>I want:</p>
  
  <pre><code>10
  22
  33
  45
  </code></pre>
  
  <p>I have tried to convert to JSON in python, and parse it in javascript, but can't seem to convert this string to an array, or keep getting errors.
  Any ideas for the best method here?</p>