0👍
So based on your implementation, you are on the right track. You forgot to run the following
python manage.py runworker long-task
The print message would display there. More information is provided here https://channels.readthedocs.io/en/latest/topics/worker.html
0👍
If after runworker, it’s still not working, see below.
The manual says:
Also remember that if you are sending the event from a synchronous environment, you have to use the asgiref.sync.async_to_sync wrapper as specified in channel layers.
So you should try this in your view:
async_to_sync(channel_layer.send)("long-task", {"type": "long.task", "text": 'Hey!'})
- [Django]-Import data into Django model with existing data?
- [Django]-Records getting deleted from Mysql table automatically
Source:stackexchange.com