django.core.exceptions.ImproperlyConfigured:无法导入ASGI_APPLICATION模块'project.routing'

时间:2019-06-22 12:24:35

标签: python django django-channels socketchannel

我已经安装了django频道,并在项目根文件夹中添加了routing.py并添加了以下代码行: ASGI_APPLICATION = 'project.routing.application' 但是每当我尝试运行服务器时 我得到

   raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)

django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'scrapshut.routing'

将频道版本降级到1.5可以,但是我想弄清楚频道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

我只希望服务器识别路由应用程序并开始工作

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:每当我从项目文件夹导入路由应用程序

from project import routing

现在我收到此错误

    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

0 个答案:

没有答案