Installing Channels and Daphne
You are going to add Channels to your project and set up the required basic ASGI application routing for it to manage HTTP requests.
Install Channels in your virtual environment with the following command:
python -m pip install -U 'channels[daphne]==4.1.0'
This will simultaneously install Channels along with the Daphne ASGI application server. An ASGI server is necessary for handling asynchronous requests, and we choose Daphne for its simplicity and compatibility, as it comes bundled with Channels.
Edit the settings.py
file of the educa
project and add daphne
to the beginning of the INSTALLED_APPS
setting as follows:
INSTALLED_APPS = [
'daphne',
# ...
]
When daphne
is added to the INSTALLED_APPS
setting, it takes control over the runserver
command, replacing the standard Django development server. This will allow you to serve asynchronous requests during development. Besides handling URL routing to...