pythondjangonode.jssocketssocket.io

What is the best approach to use Web Sockets with Django projects?


I am starting to work on a new Django project that requires sockets. I've searched internet and found this and this tutorials. There is also a lot of outdated stuff out there.

Can anyone recommend the best approach to use sockets with Django? I am using Django 1.7. Thanks.


Solution

  • Websockets are basically unsupported by django because django is based on WSGI which doesn't support websockets. My best suggestion is to use something like tornado for where you need websockets. You should be able to access all your models in tornado (could use the django templating system too if you wanted) you'll just be missing the django url system because tornado has its own.

    The suggestions you give would work too, but they're based on Socket.IO which is is javascript. If you're happy with javascript on the server side (you don't really have much of a choice on the client), then either one would be fine. If you want python, take a look at tornado.