How to setup django-channels & websockets ========================================= Avoiding constant polling is important because: #. polling is repetitive and unnecessary #. each request occupies the whole django application stack #. whatever your polling interval, it's not real time! Now, django-nyt comes with pre-configured tasks for django-channels and JavaScript snippets that will help you to quickly get started. Just follow the steps below. Configure channels ------------------ You need channels to be running a websocket server. The below example can be used for a development server, but other than that, you would have to configure a real integration with a channel worker server and Redis. .. code-block:: python INSTALLED_APPS.append('channels') CHANNEL_LAYERS = { "default": { "BACKEND": "asgiref.inmemory.ChannelLayer", "ROUTING": "django_nyt.routing.channel_routing", }, } For more on deployment, read `the Channels documentation `_. Communicating with websockets ----------------------------- On the client-side, meaning in your Django templates and static files, you need to add some JavaScript to make everything work. This is the essential stuff, copy it where ever you deem fit (it needs JQuery loaded): The essential bit below is to customize the various HTML DOM elements that are mentioned, but you can also use the same CSS class names as defined in :doc:`html`. .. code-block:: html+django