启用通道会导致 SuspiciousFileOperation 在 /
Enabling channels leads to SuspiciousFileOperation at /
我注意到,每当我在我的代码中启用 Django 通道时,当我 运行 服务器时,我会收到以下错误:
SuspiciousFileOperation at /
The joined path (C:\favicon.ico) is located outside of the base path component.
Error during template rendering
settings.py 中的以下更改产生错误:
INSTALLED_APPS = [
"channels",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"debug_toolbar",
"corsheaders",
"rest_framework",
"rest_framework.authtoken",
"core",
"drf_yasg2",
]
WSGI_APPLICATION = "app.wsgi.application"
ASGI_APPLICATION = "app.asgi.application"
asgi.py 中的以下更改产生错误:
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
application = ProtocolTypeRouter({
"http": get_asgi_application(),
# Just HTTP for now. (We can add other protocols later.)
})
就我而言,问题是由浏览器 cookie 引起的,清除 cookie 可使我的代码再次运行!
我注意到,每当我在我的代码中启用 Django 通道时,当我 运行 服务器时,我会收到以下错误:
SuspiciousFileOperation at /
The joined path (C:\favicon.ico) is located outside of the base path component.
Error during template rendering
settings.py 中的以下更改产生错误:
INSTALLED_APPS = [
"channels",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"debug_toolbar",
"corsheaders",
"rest_framework",
"rest_framework.authtoken",
"core",
"drf_yasg2",
]
WSGI_APPLICATION = "app.wsgi.application"
ASGI_APPLICATION = "app.asgi.application"
asgi.py 中的以下更改产生错误:
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
application = ProtocolTypeRouter({
"http": get_asgi_application(),
# Just HTTP for now. (We can add other protocols later.)
})
就我而言,问题是由浏览器 cookie 引起的,清除 cookie 可使我的代码再次运行!