Return StreamingHttpResponse on Signal trigger

Hi, everyone

I want to create a streaming API(server sent events) for alerts i.e new added alerts should be sent to open connections as server sent events. For that, i am using StreamingHttpResponse. Header is set to text/event-stream as it should be for SSEs. I have a model that handles alerts in DB. I have written a file that defines signal for post_save for Alert model and for post_save event on Alert model, I return StreamingHttpResponse with newly added alert. When I got the API first time, I get response with all alerts but not getting new added alert/s when ever a new alert is added to DB. What am I doing wrong?
Code snippets are in Stackoverflow question/

A StreamingHttpResponse is not an asynchronous handler - this is not the right tool for that functionality. Read the docs on it for a better understanding of what its purpose is and how it functions.

(Side note: This topic more properly belongs in the “Using Django” category, not “Django Internals”. You can recategorize it by clicking on the “pencil” icon appearing to the right of your title and changing the category.)

ok, thanks. But How can I implement the desired functionality?

There may be multiple ways of doing this - I’ve never tried to use that particular functionality myself.
My first reaction is that you’d need to do something using Channels.

You might be able to find some resources by searching for Django Channels ServerSide Events.