I want get the list from db and convert it to js associative arrays.
def lesson(request, block_id):
block_name = Block.objects.get(id=block_id)
item = Item.objects.filter(item_id=block_id)
item_json = json.dumps(item)
context = {
"item_block": block_name,
"item_json": item_json
}
return render_to_response('item_page.html', context)
In js I have
<script>
var counts = JSON.parse("{{ item_json }}");
console.log(counts)
</script>
But I have error
<QuerySet [<Item: Item object>, <Item: Item object>, <Item: Itemobject>]>
How I can get the array with objects and use it in js?