Model
class SpareParts(models.Model): vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE) amount = models.IntegerField(blank=False, null=False) date = models.DateField(blank=False, null=False)And i want to filter on the basis of vehicle and month vise and here is mine view VIEWS.py
def view_spare(request): sparepart = SpareParts.objects.all() vehicle_filter = request.POST.get('vehicle') # get the value of the date field month_filter = request.POST.get('month') # get the value of the date field if vehicle_filter: if month_filter: sparepart = sparepart.filter(vehicle=vehicle_filter,date__month=month_filter).aggregate(Sum('amount')) return render(request,'invoice/spare_parts_list.html',{'sparepart':sparepart})and i want render the whole month sum of amount in template