0
My question is as follows. I am starting my studies in Jango and find a problem. I have a function in my view with the following excerpt
def saldo_total(request):
receitas = Receitas.objects.aggregate(Sum('valor'))
total_receitas = receitas['valor__sum']
despesas = Despesas.objects.aggregate(Sum('valor'))
total_despesas = despesas['valor__sum']
receitas = receitas['valor__sum']
despesas = despesas['valor__sum']
total = total_receitas - total_despesas
return render(request, 'financas/saldo_total.html', {'total': total}, {'receitas': receitas}, {'despesas': despesas})
it makes a search in db making the sum of revenues and expenses, and also below, subtracts one by the other to inform the user’s available balance.
However, the surrender only allows me to play an attribute to the return and I would like the three to be returned.
Is there any way to do it on Django?
Thanks, buddy. It worked perfectly.
– Felipe Batista