0

I am writing a (Django-based) website which is working just fine. It displays a list of sensors and their status. If a new sensor is attached, the user needs to wait for a certain amount of time until it is warmed up and ready to use. Also, when the sensors are updated (which the user can trigger, but can also be done automatically by the system) - the user needs to wait.

On the server side I have all signals/Status updates/whatsoever available. Now I want to create an overlay for the current webpage where the statuschange is displayed for x seconds and userinput is disabled.

I have no clue what technology to use. I could frequently ask for updates client -> server but that doesn't feel like the correct way. Any suggestions on what to search for?

No code here because the answer is probably independed of my website code

Tabea
  • 39
  • 1
  • 7
  • for live editing i think you should take a look at web sockets, for package django-channels support web sockets. You basically establish a connection whenever users go to a view, instead of constantly calling the backend apis – Linh Nguyen Mar 10 '22 at 10:23

1 Answers1

2

Standard solution is to use Ajax (JavaScript) or similar to get state from your backend on specific intervals, that is the approach you're mentioning.

You can also "push" changes from your backend to frontend using WebSockets but that is a bit more complex. A popular framework is socket.io, I recommend you take a look at it.

Sputnik
  • 53
  • 4
  • Thank you very much for that quick response. Do you have any idea on how using Ajax for this usecase behaves performance wise? IE updating each second? I will have a look at WebSockets though and see if it is worth the effort. – Tabea Mar 10 '22 at 10:32
  • There is actually a pretty good guide here on how to use Django with Ajax: https://stackoverflow.com/questions/20306981/how-do-i-integrate-ajax-with-django-applications – Sputnik Mar 10 '22 at 10:36