Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Django internal ASGI handling from Channels version 4.0.0. #1688

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions tests/integrations/django/myapp/routing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import channels

from channels.http import AsgiHandler
from channels.routing import ProtocolTypeRouter

if channels.__version__ < "3.0.0":
channels_handler = AsgiHandler
else:
channels_handler = AsgiHandler()
try:
from channels.http import AsgiHandler

if channels.__version__ < "3.0.0":
django_asgi_app = AsgiHandler
else:
django_asgi_app = AsgiHandler()

except ModuleNotFoundError:
# Since channels 4.0 ASGI handling is done by Django itself
from django.core.asgi import get_asgi_application

django_asgi_app = get_asgi_application()

application = ProtocolTypeRouter({"http": channels_handler})
application = ProtocolTypeRouter({"http": django_asgi_app})