What is the most efficient way to reload a div without refreshing the whole page in django?

Question:

I am looking for the most efficient way that I can present on a live web page data such as a table with data from the database, that when a new record is added to the database the table updates itself without the user having to refresh the page.

I have tried the method with Django and Ajax but I don’t find it efficient because it has to refresh at a certain time but I only want it to refresh when a new record is added to the database.

What methods could you recommend?

Asked By: dani99

||

Answers:

With standard Ajax, the client has to initiate the request. If you want the server to be able to "push" to the client without a request from the client, you’ll want to use websockets. There’s a package called Django Channels for implementing websockets in Django.

Answered By: Kyle Alm
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.