I'm trying to make a personal WebApp with Django/Python, all works out so far, just that i want to display: total ammount, balance ect...... in my WebApp and i can't figure it out how to do is. Can someone help me out here? Thanks! The error i am recieving on line: total = Bills.objects.aggregate(Sum('ammount')) - "Bills is not defined"
Models.py
class Bills(models.Model):
bank = models.CharField(max_length=40)
name = models.CharField(max_length=40)
ammount = models.DecimalField(max_digits=10, decimal_places=2)
total = Bills.objects.aggregate(Sum('ammount'))
def __str__(self):
return self.bank
Views.py
def index(request):
return render(request, 'budget/index.html')
def bills(request):
bills_list = Bills.objects.order_by('id')
context = {'bills_list': bills_list}
return render(request, 'budget/bills.html', context)