3π
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.
2π
Make sure youβve installed it and double check youβve activated the virtualenv.
pip install -U asgi_redis
- [Django]-Attaching csv file to email in django
- [Django]-How to avoid repeated values retrieved from database?
- [Django]-Django DateTimeField input Form
- [Django]-Django: Accessing Logged in User when specifying Generic View in urlpatterns
1π
Use
pip show channels
To see the version of your package.
channels.asgi was not there until version 0.9:
https://github.com/andrewgodwin/channels/tree/0.8/channels
https://github.com/andrewgodwin/channels/tree/0.9/channels
- [Django]-Working with django : Proxy setup
- [Django]-How to add images to a Pdf file from static files using borb library and Django
- [Django]-Django β use same column for two foreign keys
1π
More than likely the asgi.py file you created is in the wrong directory.
It should be in the same directory as your settings.py and wsgi.py files.
- [Django]-Locating file path from a <InMemoryUploadedFile> Django object
- [Django]-Django: Form save override
- [Django]-Django REST browser interface
- [Django]-Django and date range picker component for Twitter Bootstrap
- [Django]-How to stop server ran in Daemon mode in Django?
1π
I ran into this issue when I was debugging a server and running the daphne command from the command line. I was running a command like:
/home/myuser/.virtualenvs/myapp/bin/python /home/myuser/.virtualenvs/myapp/bin/daphne -b 0.0.0.0 -p 8080 core.asgi:channel_layer
And it was still failing. Turns out I had to cd
into the same directory as manage.py
to get it running. If youβre using something like systemctl
, you can just set the working directory to the same location.
- [Django]-How to tell Django, that memcached running with item-size larger than default?
- [Django]-Passing context from child to parent template in Django
- [Django]-Django Multiple Levels Choices for Field
- [Django]-Django creates the test database for Postgresql with incorrect sequences start values