save instance after changed field value

This commit is contained in:
Angger 2022-08-02 16:20:31 +07:00
parent 5d7aca80d9
commit 9365d6323c

View file

@ -401,6 +401,7 @@ class NotificationViewSet(viewsets.ModelViewSet):
def set_read(self, request, pk):
notification = Notification.objects.filter(id=pk).first()
notification.is_read = True
notification.save()
serializer = NotificationSerializer(notification)
@ -410,6 +411,7 @@ class NotificationViewSet(viewsets.ModelViewSet):
def set_unread(self, request, pk):
notification = Notification.objects.filter(id=pk).first()
notification.is_read = False
notification.save()
serializer = NotificationSerializer(notification)