Answer the question
In order to leave comments, you need to log in
How to send a Response to a specific user in Django?
Good day, there is a signal to save the message in the database, that is, when one user sends a message to another, the other (if he is online, that is, he has a web socket open) should receive a notification
. As I understand it, this requires on the client side to send a JsonResponse with the necessary data, but the whole problem is that I do not know how to send a response to a specific user.
That is, something like this:
def notification(sender, **kwargs):
user = kwargs.get("instance").user
if user.is_online:
return JsonResponse(to_client=user)
else:
pass
Answer the question
In order to leave comments, you need to log in
No way, answers are sent in response to requests. If the user has a websocket open, then send a notification and and send it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question