Chartjs-Django Chart.js ajax javascript "string data parsing error"

1👍

Rather than trying to output the whole labels list directly as a Javascript array, it may be better to build a Javascript array from the list:

var data = {
    labels: [{% for label in labels %}"{{ label }}", {% endfor %}],
...

0👍

You have to use safe template filter.

safe marks a string as not requiring further HTML escaping prior to output.

Example:

{{ labels|safe }}

0👍

thank you for your suggestion.
I just converted from

   python 2.7 to python 3.7

It works perfectly fine.

Leave a comment