django-views

How can i update a django template in real time?

旧时模样 提交于 2020-08-25 03:46:39
问题 In this template i'm retrieving the price of Bitcoin from an API. At the actual moment, the price will be updated only when the page is refreshed, while i would like it to be updated without refreshing the whole page, dynamically. This is my view: def home(request): symbol = "BTCUSDT" tst = client.get_ticker(symbol=symbol) test = tst['lastPrice'] context={"test":test} return render(request, "main/home.html", context ) And the template's line looks something like this: <h3> var: {{test}} </h3>

How can i update a django template in real time?

自闭症网瘾萝莉.ら 提交于 2020-08-25 03:46:28
问题 In this template i'm retrieving the price of Bitcoin from an API. At the actual moment, the price will be updated only when the page is refreshed, while i would like it to be updated without refreshing the whole page, dynamically. This is my view: def home(request): symbol = "BTCUSDT" tst = client.get_ticker(symbol=symbol) test = tst['lastPrice'] context={"test":test} return render(request, "main/home.html", context ) And the template's line looks something like this: <h3> var: {{test}} </h3>