This is my models
class Notification(models.Model):
is_read = models.BooleanField(default=False)
and this is my views
class NotificationListCreateView(generics.ListCreateAPIView):
queryset = Notification.objects.all()
serializer_class = NotificationSerializer
class NotificationDetailView(generics.RetrieveUpdateAPIView):
queryset = Notification.objects.all()
serializer_class = NotificationSerializer
In my NotificationDetailView I want to add functionality when a notification views in detail the is_read field should True.
Update the item with:
this will set the item on
is_readbefore serializing it. We can also do this after serializing it with:but this will make one additiona query.