I need to sort the items queryset, introducing the obsolescence of content. (Content is ManytoMany related with Item class). Is it possible to filter the contents by pub_date within an annotation?
My code works here for every content publication date. I need the annotate function to work for "pub_date > '2012-10-10'" (for example).
self.queryset = Item.objects.all()
self.queryset = self.queryset.annotate(
Count("content")).order_by("-content__count")
I tried to filter with the extra() function, which doesn't work:
self.queryset = self.queryset.extra(select={
'content': "pub_date > '2012-10-10'"}).annotate(
Count("content")).order_by("-content__count")