0

I have a production Django application that is being used to view a dashboard of sensor data. Currently my sensors are sending their values to my database via Django REST framework. So I am passing the sensor values in JSON format using python requests, which then saves a record each time it receives the data.

This works well when I am sending sensor data every 30 minutes, however I want to see certain sensor data as real-time as reasonable.

Would it be practical to keep my existing setup, but just post the sensor data every 2 seconds, and use AJAX to update the page every 2 seconds? Or should I be taking a completely different approach here. Any help is appreciated!

MattG
  • 1,682
  • 5
  • 25
  • 45
  • 1
    Not certain in Django, but look up server side events or push notifications. Here is an example in flask; https://stackoverflow.com/questions/12232304/how-to-implement-server-push-in-flask-framework – SteveJ Aug 15 '19 at 19:58
  • 2
    I've used [django channels](https://channels.readthedocs.io/en/latest/) for a similar app where I was reading data from a scale. – bromosapien Aug 15 '19 at 20:08
  • 2
    I have used ajax to update a dashboard every second or so. If your query is not heavy and your application does not demand very high accuracy on the 2 seconds update you have set, then ajax would do just fine, and the application is much simpler than adding an asynchronous functionality. – devdob Aug 15 '19 at 21:24
  • Thanks for the comments guys. I will look into your suggestions – MattG Aug 16 '19 at 22:09

0 Answers0