[Answered ]-Django view variable not presenting any data in html

2👍

✅

Can you try like this ?

in python:

def index(request):
    context = "Temp = {0} *C".format(sensor.read_temperature)
    return render(request, 'hud/index.html', {"context": context})

in template:

<h1>{{ context }}</h1>

you should send variables with dictionaries {“context”: context} is our dictionary. In Django templates, data passed by key, so we can get it with {{ context }}. You have to pass an object to get with doted (index.context) syntax.

Leave a comment