I'd like to annotate a field by using conditional expressions. However, Django ORM doesn't allow to compare Avg('rating') and 5. I could calculate average rating before the query but I don't know whether it's a proper and efficient way.
queryset = (
Item.objects.filter(
status='Live'
).annotate(
group=Case(When(Avg('rating')=5, then=0))
)
)