F
F
Fedor_PV2018-08-08 05:02:39
Django
Fedor_PV, 2018-08-08 05:02:39

How to notify the user about a new incoming message in Django?

Hello! Tell me in which direction to move in order to implement a user notification of a new incoming private message? There is a simple model with the fields "Sender-Recipient-Subject-Text_Message", in the view for each specific user there is the ability to see all incoming messages from all other users, the ability to see all outgoing messages, the ability to see the personal correspondence of a specific user with a specific recipient, etc. . Everything is simple, without any web-socket and django-channel (I have not grown up to them yet).
So, the question is whether it is actually possible with such a model to somehow register the possibility for the user to learn about new incoming messages, for example, so that some kind of notification appears next to the "messages" button ? Notification by email is not interesting - I have already implemented this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-08-08
@Fedor_PV

You can't live without channels in real time. When the page is updated by the user, you can. To do this, you must either store the last message read by the user, select newer ones and show their number, or create a new model of the Notification type and create these Notifications when sending a message to the user, and show them when the page is refreshed and immediately delete them. Well, in both cases, you can add a skeleton in the form of periodic ajax requests to get information about new messages, for the illusion of interactivity. You just need to understand that polling can create a significant load on the server even from a small number of users.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question