I am not able to access an array of dicts passed from python script to javascript. When I use the following code, there is no alert message popping up. What am I doing wrong here?
errors = [1, 2]
graphs = [{'A': 1}, {'B': 2}]
return render(request, 'index.html', {'errors': errors, 'graphs': graphs})
# index.html
<script>
if ({{ graphs }}){
    alert('Detected');
}
if ({{ errors }}){
    alert('Detected');
}
</script>
I even tried converting this to json, but still same problem.
mygraphs = json.dumps(graphs)
return render(request, 'index.html', {'errors': errors, 'graphs': mygraphs})
I am able to access the array fine inside the HTML.
{% for graph in graphs %}
    <li style="color: red;">Element detected</li>
{% endfor %}
prints out Element detected twice. But I am not able to do this inside the script.
 
     
     
    