<https://stackoverflow.com/posts/71687249/timeline>
I have my query written to get some thing from database and display on my website that query is getting all the data from db but what if i want to get the data particular to current year only def get(self, request, *args, **kwargs): filters = self.get_filters() result = Model.objects.all().filter(*filters).distinct().aggregate( t=Sum('t'), b=Sum('b'), ) result2 = Model.objects.all().filter(*filters).distinct().aggregate( past_due=Sum('balance', filter=Q(due_date__lt=timezone.now())) ) zero = Decimal('0.00') total = result['t'] or zero balance = result['b'] or zero past_due = result2['past_due'] or zero amount_received = t - b -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f0959467-786f-4701-9d68-abd2e54c3aaan%40googlegroups.com.