[Answered ]-Get sum based on another field django

1👍

You can filter the investment_set and thus only retain the Investments with status='received':

@property
def amount_invested(self):
    return self.investment_set.filter(
        status='received'
    ).aggregate(Sum('invested'))['invested__sum'] or 0

Leave a comment