[Answer]-Get objects in query based on user

1👍

You just need to add the corresponding filter criteria (This example shows filter on loggedin user )

user = self.request.user

benefits = Benefit.published.all()
used_benefit_list = benefits.filter(used_benefit__isnull=False, used_benefit__user = user)
unused_benefits_list = benefits.exclude(id__in = used_benefit_list)

context = {'used_benefit_list': used_benefit_list, 'unused_benefits_list': unused_benefits_list}

Leave a comment