Django, division between two annotate result won't calculate correctly
问题 I'm trying to get a division between two annotate results in queryset. Impression is much larger than click, so I should get tenth decimal. def get_queryset(self): return googleData.objects.filter(account=self.account_name).\ values('date').\ annotate(Sum('click'), Sum('impression'), Sum('converted_click'), Sum('conversion_value'), Sum('cost'), Sum('conversion_value'), ctr_monthly= Sum('click')/Sum('impression')).\ order_by('-date') Trouble here: ctr_monthly= Sum('click')/Sum('impression'))