I am trying to implement a data collection system using iot devices. currently the data transmission is through an API using django REST framewokrs. That works excellent I would like to know some approach so that a trigger is generated when it receives data and these on the user's website are refreshed using ajax. maybe the use of signals but would not know how to bind that signal with ajax. I am somewhat newbie to javascript. some path should I follow?
CodePudding user response:
An Ajax request is just a normal HTTP request. The request is sent to a normal view. A Django signal is connected by a sender and a receiver. I'm not sure what's being sent in your case, but a prime example that's used in the Django docs is to have a post_save signal for a model object. If an object (from a model) calls save or is created, then a signal is sent. So if you save an object while handling your view logic, then the signal will run.
Is this what you're looking for? If you're thinking of doing something asynchronously so that you can send a response back to the client immediately and process whatever you want later on, then check out celery or Django-q.
CodePudding user response:
You may want to use your model signals. But that's only if you are trying to save something to the database.