From 98fc6082853cc62502911d5851db26cfc4ee2389 Mon Sep 17 00:00:00 2001 From: Kennedy Kori Date: Mon, 17 Oct 2022 14:12:17 +0300 Subject: [PATCH] feat: integrate django channels into the project (#49) This will help the project integrate other non-http protocols such as websockets in the future thus making this a robust platform to serve metadata and receive data from IDR clients. --- config/asgi.py | 6 +++++- requirements/production.txt | 4 ++-- requirements/test.txt | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/asgi.py b/config/asgi.py index ab8da7f..57a7ba8 100644 --- a/config/asgi.py +++ b/config/asgi.py @@ -9,8 +9,12 @@ import os +from channels.routing import ProtocolTypeRouter from django.core.asgi import get_asgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") +# Initialize Django ASGI application early to ensure the AppRegistry +# is populated before importing code that may import ORM models. +django_asgi_app = get_asgi_application() -application = get_asgi_application() +application = ProtocolTypeRouter({"http": django_asgi_app}) diff --git a/requirements/production.txt b/requirements/production.txt index d3d40fe..732786a 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -19,5 +19,5 @@ grpcio~=1.49.1 # Others # ----------------------------------------------------------------------------- gunicorn~=20.1.0 -sentry-sdk~=1.9.1 -uvicorn~=0.18.2 +sentry-sdk~=1.9.10 +uvicorn~=0.18.3 diff --git a/requirements/test.txt b/requirements/test.txt index f6c4649..8e6e26a 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -20,6 +20,7 @@ django-stubs~=1.12.0 # ----------------------------------------------------------------------------- factory-boy~=3.2.1 Faker~=15.1.1 +model-bakery~=1.8.0 pytest-cov~=4.0.0 pytest-django~=4.5.2 pytest-forked~=1.4.0 @@ -27,7 +28,6 @@ pytest-sugar~=0.9.5 pytest-xdist~=2.5.0 pytest~=7.1.3 tox~=3.26.0 -model-bakery~=1.8.0 # Coverage # -----------------------------------------------------------------------------