[Answered ]-Get one related object in single request for Django ORM

2๐Ÿ‘

โœ…

* Updated to address comments *

So roughly speaking, I think this is what you would use:

Book.objects.annotate(is_liked=Case(When(like__user=self.request.user, then=True), default=False))
๐Ÿ‘ค2ps

Leave a comment