[Fixed]-Pass live data from external script to django view

1👍

You want to move all that code after for device in TDevices.objects.all(): from your command and make it a method of the TDevices model. so something like

class TDevices(...):
    [...]
    def ping(self):
         if device.bIsLogging == True:
                # collect data, etc
         return dataDict

Then the view calls device.ping() and synthesizes the returned data into the view. Sorry if it’s a little bit abstract, but the issue is really just where to put your code. Once it’s in the model it’s easy for the view to access it. Hopefully you get the gist of it.

👤nephlm

Leave a comment