I have a problem with show total number of my list. I want to count the total number of my list_value variable below, but it seems it returning an error.
AttributeError: 'QuerySet' object has no attribute 'objects' when using count
views.py
@login_required(login_url='log_permission')
def data_table(request):
if request.method=='POST':
province = request.POST['province']
municipality = request.POST['municipality']
list_value =
Person.objects.filter(province=province,municipality=municipality)
final_value = list_value.objects.count() //here is the problem
total =dats.objects.aggregate(Sum('amount'))
print(final_value)
print(total)
return render(request, 'data_table.html')
models
class Person(models.Model):
covid_id = models.CharField(max_length=50)
firstname = models.CharField(max_length=50)
middle = models.CharField(max_length=50,blank=True, null=True)
lastname = models.CharField(max_length=50,blank=True)
extension = models.CharField(max_length=50,blank=True, null=True)
province = models.CharField(max_length=50)
municipality = models.CharField(max_length=50)
barangay = models.CharField(max_length=50)
remarks = models.CharField(max_length=50)
amount = models.CharField(max_length=50)
remarks_miray = models.CharField(max_length=50)
count = models.CharField(max_length=50)