I am trying to implement Server Sent Events (SSE) in the Django Framework. It is clear to me that I can implement view as follows:
@csrf_exempt def event_stream(request): def eventStream(): yield "data:Server Sent Data\n\n" response = HttpResponse(eventStream(), content_type="text/event-stream") response['Cache-Control'] = 'no-cache' return response
But I want to call an SSE call whenever a new record is created in the database table, from the post_save table. How could I achieve this here, since eventStream here is a generator function.
source share