模块 'mysite.asgi' 在 Heroku 和 Django 应用程序上没有属性 'channel_layer'

module 'mysite.asgi' has no attribute 'channel_layer' on Heroku and Django application

我正在尝试将 Django 应用程序部署到 Heroku,但我不断收到以下错误:

2020-04-13T08:45:00.134349+00:00 app[web.1]: Traceback (most recent call last):
2020-04-13T08:45:00.134389+00:00 app[web.1]:   File "/app/.heroku/python/bin/daphne", line 8, in <module>
2020-04-13T08:45:00.134519+00:00 app[web.1]:     sys.exit(CommandLineInterface.entrypoint())
2020-04-13T08:45:00.134524+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/daphne/cli.py", line 191, in entrypoint
2020-04-13T08:45:00.134697+00:00 app[web.1]:     cls().run(sys.argv[1:])
2020-04-13T08:45:00.134699+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/daphne/cli.py", line 252, in run
2020-04-13T08:45:00.134891+00:00 app[web.1]:     application = import_by_path(args.application)
2020-04-13T08:45:00.134913+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/daphne/utils.py", line 14, in import_by_path
2020-04-13T08:45:00.135028+00:00 app[web.1]:     target = getattr(target, bit)
2020-04-13T08:45:00.135056+00:00 app[web.1]: AttributeError: module 'mysite.asgi' has no attribute 'channel_layer

这是我的 Procfile:

web: daphne WR.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2

这是我在 settings.py 上定义 Redis 的方式:

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            "hosts": [('https://mytestapp1.herokuapp.com/', 6379)],
            'capacity': 1500,
            'expiry': 2,
        },
    },
}

谁能帮我找出我做错了什么?难道我必须将 Redis heroku 插件添加到我的应用程序吗?

看到 asgi.py 会很好,但我想这可能会有所帮助。

web: daphne WR.asgi:application --port $PORT --bind 0.0.0.0 -v2