websoket qoshildi

This commit is contained in:
behruz-dev
2025-11-28 17:51:00 +05:00
parent b14062e7b9
commit aa38215428
9 changed files with 215 additions and 6 deletions

View File

@@ -1,7 +1,23 @@
import os
from django.core.asgi import get_asgi_application
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.base')
application = get_asgi_application()
django.setup()
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from django.urls import re_path
from core.apps.authentication.websocket.consumers import UserActivationConsumer
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter({
'http': django_asgi_app,
'websocket': AuthMiddlewareStack(
URLRouter([
re_path(r'^ws/user_activation/(?P<user_id>\d+)/$', UserActivationConsumer.as_asgi()),
])
),
})

View File

@@ -1,4 +1,5 @@
from .rest_framework import *
from .corsheaders import *
from .simple_jwt import *
from .drf_yasg import *
from .drf_yasg import *
from .redis import *

10
config/conf/redis.py Normal file
View File

@@ -0,0 +1,10 @@
from config.env import env
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [(env.str('REDIS_HOST'), env.str('REDIS_PORT'))],
},
},
}

View File

@@ -61,6 +61,7 @@ TEMPLATES = [
]
WSGI_APPLICATION = 'config.wsgi.application'
ASGI_APPLICATION = 'config.asgi.application'
DATABASES = {