class TradeItem(models.Model):
...
class Wishlist(models.Model):
user = models.ForeignKey(User, related_name='wishlist_user')
item = models.ForeignKey(TradeItem, related_name='wishlist_item')
I need to make TradeItem queryset annotated with a Boolean of whether an item is in this user's wishlist. Something like
items = TradeItem.objects.all().annotate(wishlist=
<heresy>
if Wishlist.objects.filter(user=request.user, item={current_item}:
True
else:
False
</heresy>
)
Is it possible to do the said thing with annotate/aggregate, and what would be the most efficient way for that in general?