Why does :
from channels.asgi import get_channel_layer
results in :
from channels.asgi import get_channel_layer
ImportError: No module named asgi
I am using Django (1.9) and python(3.4). And, while editing in pycharm, i see the IDE is giving me the quick tip for me.
I was able to fix this; if you are using channels 2, the channel layer is quite different from the older version.
I suggest you to try the following:
Confirm that you have configured your channel layer on settings.py
:
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("redis-server-name", 6379)],
},
},
}
Hopefully, you have installed redis if using redis.
Add the channel layer to asgi.py
file:
from channels.layers import get_channel_layer
channel_layer = get_channel_layer()
You can see this solution.