models.py looks like this
class Channel(Model):
name = CharField()
class Contract(Model):
channel = ForeignKey(Channel, related_name='contracts')
fee = IntegerField()
class ContractPayment(Model):
contract = ForeignKey(Contract, related_name='payments')
value = IntegerField()
When I query a model:
Channel.objects.annotate(pay=Sum('contracts__fee'))
It returns: 75000. And Its correct but when I query like this:
Channel.objects.annotate(pay=Sum('contracts__fee'))
.annotate(paid=Sum('contracts__payments__value'))
And it returns: pay: 96000, paid: 33000. As you can see the pay is changed. What is going on here? I read the ticket #10060 but no luck.