I noticed that whenever I enable django channels in my code, I get the following error, when I run the server:
SuspiciousFileOperation at /
The joined path (C:\favicon.ico) is located outside of the base path component.
Error during template rendering
Following changes in settings.py produce the error:
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"
Following changes in asgi.py produce the error:
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.)
})
In my case, the issue was caused by browser cookies, clearing the cookies makes my code work again!