How to pass context django by jquery?

views.py
def item_cost(request):

item_group = itmecost.objects.values('reference')\
	.order_by('group')\
	.annotate(total_group=Sum('total'))
items cost varibles
supplyer = item_group[3].get('total_group')

context = {
	'supplyer': supplyer,
}
return render(request,"president/item_cost.html",context)

jquery.js
$(“h1.resultval”).html("{{supplyer}}");


in need to pass context django by jquery
the result apear text only

If you want to access the full model attributes on jquery you need to pass the context as a json string then part it back to a object in javascript.

import json
from django.core import serializers

def getObject(request):
    item_group = itemcost.objects.values('reference')...
    supplier = item_group[3].get('total_group')

    data = serializers.serialize('json', [supplier,]) # returns a json list but you only need the single supplier.
    struct = json.loads(data)
    supplier_json = json.dumps(struct[0]) # return the single supplier object
    context = {
	    'supplier': supplier_json,
    }
    return render(request,"president/item_cost.html",context)

You can then parse supplier as an object rather than a string in jquery:

<script>
const supplier = JSON.parse({{supplier}});

console.log(supplier);
/// {id: 1, name: "...."}
</script>