The*_*ter 18 python django django-channels
我按照频道文档中的教程进行操作,但是当我启动服务器时,python3 manage.py runserver
它给了我这个:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
October 17, 2022 - 00:13:21
Django version 4.1.2, using settings 'config.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)
当我期望它给我这个时:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
October 17, 2022 - 00:13:21
Django version 4.1.2, using settings 'config.settings'
Starting ASGI/Channels version 3.0.5 development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)
设置.py
INSTALLED_APPS = [
'channels',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
...
]
ASGI_APPLICATION = 'config.asgi.application'
Run Code Online (Sandbox Code Playgroud)
阿斯吉
import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = ProtocolTypeRouter({
'http': get_asgi_application(),
})
Run Code Online (Sandbox Code Playgroud)
ASGI_APPLICATION = 'config.asgi.application
即使我将其更改为,它也不会给出任何错误ASGI_APPLICATION = ''
。
rez*_*afi 12
一开始:
pip install daphne
pip install channels
Run Code Online (Sandbox Code Playgroud)
然后更新setting.py:
INSTALLED_APPS = [
'daphne',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Run Code Online (Sandbox Code Playgroud)
只是这个。
小智 11
与 django=4.1.4 相同,channels=4.0.0
我的解决方案:
python -m pip install -U channels["daphne"]
INSTALLED_APPS = ( "daphne", "django.contrib.auth",...
ASGI_APPLICATION = "myproject.asgi.application"