I have a Notification List view and this function
def mark_as_read(request, notification_id):
notification = get_object_or_404(Notification.objects.filter(pk=notification_id).exclude(viewed_at__isnull=False))
notification.viewed_at = datetime.datetime.now()
notification.save()
return redirect('users:notification')
It works good but I think it is written not correct? Any body can tell it correct here working get_object_or_404?