Calculate Total Sales in View
from django.shortcuts import render
from .models import Sale
def sales_report(request):
sales = Sale.objects.all()
total_sales = sales.aggregate(total=models.Sum('total_price'))['total']
return render(request, 'sales_report.html', {'sales': sales,
'to
total sale
from django.shortcuts import render
from .models import Sale
def sales_report(request):
sales = Sale.objects.all()
total_sales = sales.aggregate(total=models.Sum('total_price'))['total']
return render(request, 'sales_report.html', {'sales': sales,
'total_sales': total_sa
Good day
I am struggling with the following task, may you please assist? bellow are
the instructions:
[image: image.png]
Kind Regards,
Siphiwe Nyathi
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop rece
3 matches
Mail list logo