Skip to content

fix(blog): correct inverted last_page context value in blog_index#909

Open
SAY-5 wants to merge 1 commit intomemeLab:developfrom
SAY-5:fix/blog-index-last-page-inverted
Open

fix(blog): correct inverted last_page context value in blog_index#909
SAY-5 wants to merge 1 commit intomemeLab:developfrom
SAY-5:fix/blog-index-last-page-inverted

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 18, 2026

Problem

blog_index in src/blog/views.py populates last_page in the
template context with page.has_previous():

context = {
    ...
    "last_page": page.has_previous(),
    ...
}

Paginator.Page.has_previous() returns True whenever there are
pages before the current one — i.e., for every page except
page 1. The variable name promises the opposite: last_page should
be True only when the reader has reached the final page.

Downstream templates use last_page to terminate the "load more"
cycle / show an end-of-feed marker. With the old value the feed
appeared to end as soon as the reader clicked past page 1, regardless
of how many posts actually remained. #857.

Fix

Use the semantic opposite that actually matches the variable name:

- "last_page": page.has_previous(),
+ "last_page": not page.has_next(),

page.has_next() returns False only on the final page, so
not page.has_next() is True exactly when the reader has reached
the end of the feed.

Fixes #857

blog_index set `last_page` in the template context to
`page.has_previous()`. has_previous() is True for every page except
page 1, which is the opposite of what the variable name promises. The
template uses last_page to stop the "load more" / end-of-feed path, so
with the old value the feed appeared to reach the end as soon as the
reader moved past page 1, even when more posts remained.

Set last_page to `not page.has_next()` so it is True only once the
user is actually on the final page.

Fixes memeLab#857

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blog_index view has inverted last_page logic using has_previous() instead of not has_next()

1 participant