[Answered ]-Django query database and send data to template

2👍

Send value in JSON format to template:

from django.core import serializers

def adv(request):
    adv.objects
    a = adv(id = '1103804') #Will fetch all the column
    a = adv(id = '1103804').values('columnName') #Will fetch the particular column.
    data = serializers.serialize('json', a)
    context = Context(data)
    return render(request,'toa/graphs.html',context)
    render(request, "foo.html", {'jsonKey': jsonValue}) #For passing individual JSON

Leave a comment