Chartjs-Issue in making a Pie Chart using django with fully dynamic data

0👍

To generate the list you could do:

labels: [{% for key, value in pie.items %}"{{key}}",{% endfor %}]

Output: ["Key1","Key2","Key3"]

data: [{% for key, value in pie.items %}{{value}},{% endfor %}]

Output: [1,0,0]

You don’t have a comma, and the string is encapsulating the entire for loop in your example.

This should work.

(Even though it looks a little weird in the html script tag)

Leave a comment