I am using Django channels in my project using using official Django channels v2
, my simple channels app is completed and working fine if run python manage.py runserver
but I want to run Django channels on a different port so I am now using daphne. When I use daphne
with run command my_project.asgi:application --port 8001
it works fine on 8001 port
INFO Starting server at tcp:port=8001:interface=127.0.0.1
INFO HTTP/2 support not enabled (install the http2 and tls Twisted extras)
and if I also run python manage.py runserver
in another terminal at the same time it works fine. Now both channels on port 8001
and Django on 8000
port works as expected but my runserver command runs my application as ASGI/Channels instead of wsgi development server,
Starting ASGI/Channels version 2.2.0 development server at http://127.0.0.1:8000/
instead of
Starting development server at http://127.0.0.1:8000/
settings.py
ASGI_APPLICATION = 'my_project.routing.application'
WSGI_APPLICATION = 'my_project.wsgi.application'
If I debug any function in views.py
request, it is ASGI request instead of Django wsgi request
asgi.py
import os
import django
from channels.routing import get_default_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
django.setup()
application = get_default_application()
My questions are as follows:
- How can I get Django WSGI request instead of ASGI request in my normal function view request(like
def index(request)
) or if we install django channels every request become ASGI request? - what is the use of the python mange.py runworker command