I have a model called Account
, with has a model function (see code below). I would like to show in my template the users total on every page. The only way I can think of doing this in putting accounts in every view. What other options do I have? Can it be liked to request.user? I already have access to request in every view and Accounts has the FK user.
def _balance(self):
aggregates = self.transactions.aggregate(sum=Sum('amount'))
sum = aggregates['sum']
return D('0') if sum is None else sum