23👍
✅
Full answer following @Alasdair’s comment:
from django.db.models import FloatField
from django.db.models.functions import Cast
qs = MyModel.objects.order_by('name').values('name').annotate(
count=Cast(Count('name') / 2.0, FloatField()))
👤Udi
Source:stackexchange.com