diff --git a/district/models.py b/district/models.py index adc4abe420fcc2d058fd51a4ba0ff70c932061c5..3b5c0017317f09d357423d850f1b56861f7d1950 100644 --- a/district/models.py +++ b/district/models.py @@ -193,7 +193,13 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page): @property def articles(self): - return self.get_descendants().type(DistrictArticlePage).live().specific()[:6] + return ( + self.get_descendants() + .type(DistrictArticlePage) + .live() + .specific() + .order_by("-last_published_at")[:6] + ) @property def articles_page(self): @@ -271,7 +277,7 @@ class DistrictArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Page): self.get_siblings(inclusive=False) .live() # TODO? filtrovat na stejné tagy? .specific() - .order_by("-uniwebarticlepage__date")[:3] + .order_by("-last_published_at")[:3] ) return context @@ -302,7 +308,7 @@ class DistrictArticlesPage(SubpageMixin, MetadataPageMixin, Page): def get_context(self, request): context = super().get_context(request) context["articles"] = Paginator( - self.get_children().live().specific(), + self.get_children().live().specific().order_by("-last_published_at"), self.max_items, ).get_page(request.GET.get("page")) return context @@ -388,7 +394,7 @@ class DistrictTagsPage(SubpageMixin, MetadataPageMixin, Page): return { "article_page_list": Paginator( - article_page_qs, + article_page_qs.order_by("-last_published_at"), self.root_page.articles_page.max_items, ).get_page(request.GET.get("page")), "tag": tag, diff --git a/region/models.py b/region/models.py index fcd921baaf22370cc4bd9d2f4faf5f5c01de89c5..2c88828d277807943244d46a164e86cb4280db32 100644 --- a/region/models.py +++ b/region/models.py @@ -193,7 +193,13 @@ class RegionHomePage(MetadataPageMixin, CalendarMixin, Page): @property def articles(self): - return self.get_descendants().type(RegionArticlePage).live().specific()[:6] + return ( + self.get_descendants() + .type(RegionArticlePage) + .live() + .specific() + .order_by("-last_published_at")[:6] + ) @property def articles_page(self): @@ -269,7 +275,7 @@ class RegionArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Page): self.get_siblings(inclusive=False) .live() .specific() - .order_by("-uniwebarticlepage__date")[:3] + .order_by("-last_published_at")[:3] ) return context @@ -300,7 +306,7 @@ class RegionArticlesPage(SubpageMixin, MetadataPageMixin, Page): def get_context(self, request): context = super().get_context(request) context["articles"] = Paginator( - self.get_children().live().specific(), + self.get_children().live().specific().order_by("-last_published_at"), self.max_items, ).get_page(request.GET.get("page")) return context @@ -386,7 +392,7 @@ class RegionTagsPage(SubpageMixin, MetadataPageMixin, Page): return { "article_page_list": Paginator( - article_page_qs, + article_page_qs.order_by("-last_published_at"), self.root_page.articles_page.max_items, ).get_page(request.GET.get("page")), "tag": tag,