【问题标题】:How to delete notification by using django-notifications-hq如何使用 django-notifications-hq 删除通知
【发布时间】:2021-08-01 05:20:31
【问题描述】:

我们如何查询和选择通知的特定 id..?

现在我正面临以下问题...您可以在其他部分看到我正在发送通知,说明有人关注了其他人。现在在如果一个人取消关注他关注的人时选择。应该删除该通知,以便当他再次关注时,先前的通知会被删除并生成新的通知。我期待你们的善意和帮助。谢谢!:)

if follower:
        profile_.follower.remove(follower.id)
        actor = User.objects.get(pk=user_id)
        user = User.objects.get(username=username_to_toggle)
        query = Notification.objects.filter(id__in=notificacion_ids).update(deleted=True) #notificacion_ids(I don't understand how to get that.)
        print(query,"hey heyh eh")
        # json_follower = some_view(user)
    else:
        new_follower = User.objects.get(username__iexact=username_to_toggle)
        profile_.follower.add(new_follower.id)
        actor = User.objects.get(pk=user_id)
        user = User.objects.get(username=username_to_toggle)
        notify.send(actor, recipient=user, verb='follow you')
        # json_follower = some_view(username_to_toggle)
        is_following = True  

【问题讨论】:

    标签: django api django-models django-views notifications


    【解决方案1】:

    然后,您将使用“参与者”和“收件人”过滤通知模型。像这样的:

    notification_ids =Notification.objects.filter(actor_object_id=actor.id,recipient_id=user.id).values_list('id', flat=True)
    

    【讨论】:

      猜你喜欢
      • 2019-02-24
      • 1970-01-01
      • 2015-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多