Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_queryset(self):
- user = self.request.user
- queryset = Notification.objects.annotate(Count('album'), Count('video'))
- notifs_of_albums = queryset.filter(album__count__gte=1)
- notifs_of_videos = queryset.filter(video__count__gte=1)
- notifs_of_albums_to_user = notifs_of_albums.filter(
- album__artist__in=Artist.objects.filter(subscriptions__subscriber=user)
- )
- notifs_of_videos_to_user = notifs_of_videos.filter(
- video__channel__in=Channel.objects.filter(subscriptions__subscriber=user)
- )
- all_notifs_to_user = notifs_of_albums_to_user | notifs_of_videos_to_user
- return all_notifs_to_user.order_by('-creation_date_time')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement