Django countdown timer

Hello is it possible to create a running time in django?

For example, clicking the start button will trigger the time, and when the browser closed or the connection lost, the time is still running on the background. I am not sure if this is possible in django model, so i can just query the field again and re-render it on the front-end.

There is no such thing as “connection lost”. Each page request is a separate connection that is established and ended when a page is rendered.

I’m not sure what you’re looking to determine. If you can be more specific as to what it is you’re trying to monitor, we might be able to offer some suggestions.

1 Like

Let say there is a task, and i want to get the spent time of each task that have completed. But I also need to display the timer when the start button is clicked.


As you can see on the above image, that timer is running continuously even when the browser is closed and once we return back to the webpage (browser closed for about a minute) that timer should be in a minute and 20 seconds.

That’s a slightly different issue.

You don’t need to keep a “running clock”. Store the time when a task was started, and then when you need to get the elapsed time, calculate the difference between the current time and the start time.

1 Like

Ohhhh that’s right thank you so much! Hahaha

Hi I am creating a quiz app where user has to complete test within particular time, so for this I am implementing a time counter in frontend with javascript but if we refresh the page it will reset again so I want to start a time counter parallel in django whenever user click on start button, so that even user refresh the page based on backend time counter we can show how much time left, could you please suggest how can we implement a time counter in django

This issue has been marked as solved - please open up a new topic for this discussion as it is not part of the previous conversation.