Search code examples
pythondjangoweb-applicationsreal-time

How can i send real time data to a Django application and show it on a webpage?


I'm trying to add real-time features to my Django webapp. Basically, i want to show real time data on a webpage.

I have an external Python script which generates some JSON data, not big data but around 10 records per second. On the other part, i have a Django app, i would like my Django app to receive that data and show it on a HTML page in real time. I've already considered updating the data on a db and then retrieving it from Django, but i would have too many queries, since Django would query the DB 1+ times per second for every user and my external script would be writing a lot of data every second.

What i'm missing is a "central" system, a way to make these two pieces communicate. I know the question is probably not specific enough, but is there some way to do this? I know something about Django Channels, but i don't know if i could do what i want with it; i've also considered updating the data on a RabbitMQ queue and then retrieve it from Django, but this is not the best use of RabbitMQ.

So is there a way to do this with Django-Channels? Any kind of advice is appreciated.


Solution

  • I would suggest using Django Channels. You can also use Redis instead of RabbitMQ. In your case, Redis might be a better choice.
    Here is an approach: http://www.maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/