I want to make a notification system in django so that, when you add a new entry to the database I get notified. As admin I do everything in the Django Rest API
Advertisement
Answer
JavaScript
x
15
15
1
def create_profile(sender, instance, created, **kwargs):
2
if created:
3
instance.rooms.room_bool = instance.room_bool
4
instance.rooms.save()
5
token = '5419477:AAHuyagslasglfsE9O-90vgiDHVTiV2KmqFRNw'
6
URL = 'https://api.telegram.org/bot' + token + '/sendMessage'
7
for chat_id in ADMINS:
8
try:
9
data = {'chat_id': chat_id, 'text': "Забронирован один номер через Ресепшенnn"
10
"Посмотрите по ссылке http://127.0.0.1:8000/admin/reg_admin/registration/nn"
11
"Нажмите /start чтобы вывести меню администратора"}
12
requests.post(URL, data=data)
13
except Exception:
14
pass
15
using signals.py, I sent a message to the bot via json