Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ошибка AttributeError at /api/v1/applicant/applicants/
- 'list' object has no attribute 'id' Возникает когда в вызове ложу скобки []
- Код
- def send_notification(data, user, req_user, email):
- channel_layer = get_channel_layer()
- group_name = 'user_id_{0}'.format(user.id)
- print(group_name)
- for group in group_name:
- async_to_sync(channel_layer.group_send)(group,
- {
- "type": "notify",
- "text": data,
- },
- )
- if email:
- send_mail(subject='Уведомление', message=f"{data}", from_email=req_user.email,
- recipient_list=[user.email]) # from_email-от кого и recepient_list-кому
- notify = Notification.objects.create(sender=req_user, message=data)
- notify.receivers.add(user)
- notify.save()
- Вызов
- applicant1 = User.objects.all().get(username="applicant1")
- applicant2 = User.objects.all().get(username="applicant0")
- notify_text = 'SomeMessageforGroup'
- send_notification(notify_text, user=[applicant1, applicant2], req_user=user_id,
- email=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement