How to Use Socket.io to send Messages from views.py ?

No, the issue is that you’re trying to handle websockets within a Django view.

You can’t do that.

Handling websockets is something that must be done outside the regular Django environment. That’s where things like Channels comes into play.

Also see Send Notifications in real time using Python Engineio