2👍
google.visualization.arrayToDataTable() appears to take a 2D (javascript) array. What you are passing it is a string. You’ll need to parse it into an array. Try:
var djangoData = JSON.parse('{{ array }}');
var data = google.visualization.arrayToDataTable(djangoData);
2👍
In your view:
remove this line args['array']= array
change this line return render_to_response('progress.html',args)
to return render_to_response('progress.html',{'array': json.dumps(array)})
In your template:
change this line var djangoData = '{{array}}';
to var djangoData = '{{ array | safe }}';
The rest of your code is fine. I hope this helps.
0👍
for me this combination works:
view:
from django.shortcuts import render
import json
(...)
context= {'array': json.dumps(array)}
return render(request,'progress.html',context)
template:
var djangoData = JSON.parse('{{ array | safe }}';);
Source:stackexchange.com