Python datastructures into js datastructures using Django templates (lists and dicts)
问题 I have a Django view that returns a list of dicts like so data = [{'year': 2006, 'books': 54}, {'year': 2007, 'books': 43}, {'year': 2008, 'books': 41}, {'year': 2009, 'books': 44}, {'year': 2010, 'books': 35}] c = { 'data': data, } return render(request, 'template.html', c) The template file has some basic JavaScript in it that does something like this. var data = "{{data}}"; console.log(data); //..... Then other functions The issue is that the data is coming into the JavaScript via the