Search code examples
javascriptdjangodatabasewebsocketdjango-channels

How to fetch data at the moment the database updates, without refreshing the page, in Django?


In a web application that I'm building using Django, there is a filed in the main page that fetches a price float from the database and shows it, and I need it to be updated every time that the source price (in the database) gets updated, or within some seconds. And I need that to be without refreshing the page, kind of live you can say.

Is there any possible way to reach this without using Django channels, e.g. by using JavaScript or anything else?


Solution

  • As @SergueiA suggested in a comment, I searched for Django Ajax and found this vide. And YES IT WORKED!

    Using JavaScript and setInterval(), the price is updating every second now.