title: Django how to correctly acces the context array in javascript?
body: <p>My question is similar to the these previous questions, however I can't seem to make my code work:</p>
  <p><a href="https://stackoverflow.com/questions/8683922/how-can-i-pass-my-context-variables-to-a-javascript-file-in-django">How can I pass my context variables to a javascript file in Django?</a></p>
  <p><a href="https://stackoverflow.com/questions/43305020/how-to-use-the-context-variables-passed-from-django-in-javascript">How to use the context variables passed from Django in javascript?</a></p>
  <p>I have a list of lists, containing data of the form:</p>
  <pre><code>data = [[1, 2, 3, 4, ...] [210, 346, 331, 402, ...] [...] ...] 
  </code></pre>
  <p>where the first list represents the number of each taken sample.  I'm passing this data to my HTML file using a class that looks like:</p>
  <pre><code>class IndexView_charts(generic.TemplateView):
      &quot;&quot;&quot;
      IndexView:
      &quot;&quot;&quot;
      module = 'IndexView'
      template_name = charts_temp_name #variable for the template
  
  data = ##extra code here to fetch data
  
  def get_queryset(self):
      log(self.module, 'get_queryset', file=__file__)
      return self.data
  
  def get_context_data(self, **kwargs):
      context = super().get_context_data(**kwargs)
      context['data'] = self.data
      return context
  </code></pre>
  <p>And in the template, I can access the variable data as follows for example and it shows up on the webpage:</p>
  <pre><code>&lt;h1&gt; {{data.0}} &lt;/h1&gt;
  </code></pre>
  <p>now, I'd like to access it in my script. In the same file I have the following code:</p>
  <pre><code>var chartData = {{ data }};
  ... some more code here ...
  data:chartData[1] 
  </code></pre>
  <p>but I don't get the charts that I would like. If i change the occurrences of chartData[x] into lists containing some dummy data, the script works. So the problem lies at accessing the data.</p>