Skip to content

Commit

Permalink
Suppress error for non-existent page
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteinberg committed Mar 20, 2024
1 parent e997b79 commit 8ca5bb2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.contrib.auth.models import AnonymousUser
from django.contrib.auth.views import PasswordResetView, redirect_to_login
from django.core.exceptions import PermissionDenied
from django.core.paginator import Paginator
from django.core.paginator import Paginator, EmptyPage
from django.core.validators import URLValidator
from django.db import transaction
from django.db.models import Q
Expand Down Expand Up @@ -2818,7 +2818,10 @@ def as_printable_html(
logger.info(f"Rendering Casebook {casebook.id}, starting from page {page}: serializing to HTML")

paginator = Paginator(top_level_nodes, 1)
page = paginator.page(page)
try:
page = paginator.page(page)
except EmptyPage:
raise Http404
section = page[0]

node_filter = {} if whole_book else {"ordinals__0": section.ordinals[0]}
Expand Down

0 comments on commit 8ca5bb2

Please sign in to comment.