14đź‘Ť
Apparently, I perceived the meaning of .values('project')
differently/wrongly.
So the following worked for me.
private_donations = PrivateDonation.objects.filter(project=OuterRef('pk')).order_by().values('project')
private_donations_sum = private_donations.annotate(pd_sum=Sum('value')).values('value')
projects = Project.objects.annotate(sum=Subquery(private_donations_sum))
👤sajid
Source:stackexchange.com