アイテムのクエリセットを並べ替えて、コンテンツの陳腐化を導入する必要があります。(コンテンツはItemクラスに関連付けられたManytoManyです)。注釈内で pub_date によってコンテンツをフィルタリングすることは可能ですか?
私のコードは、コンテンツの公開日ごとにここで機能します。「pub_date > '2012-10-10'」で機能するには、注釈機能が必要です(たとえば)。
self.queryset = Item.objects.all()
self.queryset = self.queryset.annotate(
Count("content")).order_by("-content__count")
extra() 関数でフィルタリングしようとしましたが、機能しません:
self.queryset = self.queryset.extra(select={
'content': "pub_date > '2012-10-10'"}).annotate(
Count("content")).order_by("-content__count")