Chartjs-Python list does not work in django with ChartJS

2๐Ÿ‘

I ended up changing the labels and data field to the following:

[{% for label in graph_labels %} {{ label }}, {% endfor %}]
[{% for value in graph_values %} {{ value }}, {% endfor %}]

Notice the comma in the for loop, without it the values will not be processed correctly.

0๐Ÿ‘

{{ graph_labels }} and {{ graph_values }} are Django template variable and you are trying to access then inside javascript , this will not work. Use template tag "json_script" Django Documentation to pass data from django template to your javascript.

Leave a comment