'django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'project.routing'
I have installed django channels and I have added routing.py in project root folder and added the line
ASGI_APPLICATION = 'project.routing.application'
but whenever i tried to run the server
i get
raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'scrapshut.routing'
downgrading channels version to 1.5 works but i want to figure out whats the issue with channels 2
async-timeout==3.0.1
attrs==19.1.0
autobahn==19.6.2
Automat==0.7.0
certifi==2019.6.16
cffi==1.12.3
channels==2.2.0
channels-redis==2.3.3
chardet==3.0.4
constantly==15.1.0
cryptography==2.7
daphne==2.3.0
defusedxml==0.6.0
dj-database-url==0.5.0
Django==2.2.2
django-heroku==0.3.1
django-widget-tweaks==1.4.5
gunicorn==19.9.0
hiredis==1.0.0
hyperlink==19.0.0
idna==2.8
incremental==17.5.0
msgpack==0.6.1
msgpack-python==0.5.6
oauthlib==3.0.1
Pillow==6.0.0
psycopg2==2.8.3
pycparser==2.19
PyHamcrest==1.9.0
PyJWT==1.7.1
pypiwin32==223
python-decouple==3.1
python-social-auth==0.2.1
python3-openid==3.1.0
pytz==2019.1
pywin32==224
redis==2.10.6
requests==2.22.0
requests-oauthlib==1.2.0
six==1.12.0
social-auth-app-django==3.1.0
social-auth-core==3.2.0
sqlparse==0.3.0
Twisted==19.2.1
txaio==18.8.1
urllib3==1.25.3
i just want the server to recognize the routing application and start working
EDIT(routing.py):
from channels.routing import ProtocolTypeRouter,URLRouter
from django.urls import path
from notifier.consumers import EchoConsumer
application = ProtocolTypeRouter({
"websocket": URLRouter([
path("ws/", EchoConsumer),
])
})
EDIT2: whenever i import routing application from the project folder
from project import routing
now im getting this error
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Solution 1:[1]
I've had a similar problem which I've managed to solve.
- First: locate your asgi.py file
- Then: in your settings.py type the following:
ASGI_APPLICATION = "NAME_OF_FOLDER_WHERE_ASGI.PY_FILE_IS_LOCATED.asgi.application"
what you're doing in the settings.py file is referencing the location of the file, the actual file, and then the application variable inside that file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | nizarhamood |