28 lines
852 B
Python
28 lines
852 B
Python
![]() |
"""
|
||
|
ASGI config for role_based_system project.
|
||
|
|
||
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||
|
|
||
|
For more information on this file, see
|
||
|
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
|
||
|
"""
|
||
|
|
||
|
import os
|
||
|
import django
|
||
|
|
||
|
# 首先设置 Django 设置模块
|
||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'role_based_system.settings')
|
||
|
django.setup() # 添加这行来初始化 Django
|
||
|
|
||
|
# 然后再导入其他模块
|
||
|
from django.core.asgi import get_asgi_application
|
||
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||
|
from channels.auth import AuthMiddlewareStack
|
||
|
from user_management.routing import websocket_urlpatterns
|
||
|
|
||
|
application = ProtocolTypeRouter({
|
||
|
"http": get_asgi_application(),
|
||
|
"websocket": AuthMiddlewareStack(
|
||
|
URLRouter(websocket_urlpatterns)
|
||
|
),
|
||
|
})
|