Skip to content

Commit

Permalink
πŸ› Fix showing last article of first page again on second page
Browse files Browse the repository at this point in the history
  • Loading branch information
pajowu committed Dec 11, 2023
1 parent e714063 commit 6e27dd2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions fragdenstaat_de/fds_blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,16 @@ class ArticleListView(BaseBlogListView, ListView):
def get_queryset(self):
qs = super().get_queryset()

featured = (
qs.filter(date_featured__isnull=False).order_by("-date_featured").first()
)
self.featured = None
page = self.request.GET.get("page", None)
if not page or page == "1":
try:
self.featured = qs.filter(date_featured__isnull=False).order_by(
"-date_featured"
)[0]
except IndexError:
pass

if self.featured is not None:
qs = qs.exclude(pk=self.featured.pk)
self.featured = featured

if featured is not None:
qs = qs.exclude(pk=featured.pk)
return qs

def get_context_data(self, **kwargs):
Expand Down

0 comments on commit 6e27dd2

Please sign in to comment.