Use method as aggregate field
<p>I have two models that go as follows (for simplicity's sake):</p>

<pre><code>class Bank(models.Model):
    name = models.CharField(max_length=250)


class Person(models.Model):
    bank = models.ForeignKey(Bank)
    savings = models.IntegerField()
    debts = models.IntegerField()

    def get_net_worth(self):
        return self.savings - self.debts
</code></pre>

<p>And I want to write a method that lets me know the "total net worth" of the people in a bank, like:</p>

<pre><code>class Bank(models.Model):
    ...
    def get_net_worth(self):
        return self.person_set.all().aggregate(Sum('get_net_worth'))
</code></pre>

<p>But of course Django complains that such field does not exist:</p>

<blockquote>
  <p>django.core.exceptions.FieldError: Cannot resolve keyword 'get_net_worth' into field.</p>
</blockquote>

<p>Is there a way to achieve this without having to explicitly store the "net worth" in the database?</p>

<p><strong>Edit:</strong></p>

<p>In case you wonder, one can just do</p>

<pre><code>def get_net_worth(self):
    person_queryset = self.person_set.all()
    return person_queryset.aggregate(Sum('savings'))['savings__sum'] - person_queryset.aggregate(Sum('debts'))['debts__sum']
</code></pre>

<p>But I do have to somehow <strong>use the <code>get_net_worth</code> method</strong> on every "Person".</p>

<p><strong>Edit 2:</strong></p>

<p>Just to clarify things up: These two are not my actual models, they are over-simplified examples of what I want to achieve, and what I essentially want to do <strong>is NOT to do arithmetic between two fields</strong>, but rather <strong>use a model's method as the field for the aggregate function</strong> (of course a method can do some more complex stuff before returning a value), therefore this one is not a duplicate of the other question.</p>