I want to calculate the sum of two records but only inside the pagination.
class MacaListView(ListView):
model = Maca
paginate_by = 20
def get_context_data(self, *, object_list=None, **kwargs):
context = super(MacaListView, self).get_context_data(object_list=None, **kwargs)
maca = Maca.objects.all()
for i in range(0, maca.count()):
maca1 = Maca.objects.get(maca[i].id)
maca1.number = maca.number + 1
maca1.save()
This will go to every single record and do the logic. I want the logic to be executed for only records in pagination (do calculate for only 20 records)