# HG changeset patch # User neko259 # Date 2015-02-04 18:32:01 # Node ID 6b112efebd643d9dc34867394be0719364cc61e1 # Parent af7d403c7b042c99ec0ffd0441f6174f78c95917 Throw error 404 when trying to open invalid page in threads list diff --git a/boards/views/all_threads.py b/boards/views/all_threads.py --- a/boards/views/all_threads.py +++ b/boards/views/all_threads.py @@ -1,6 +1,8 @@ from django.core.files import File from django.core.files.temp import NamedTemporaryFile +from django.core.paginator import EmptyPage from django.db import transaction +from django.http import Http404 from django.shortcuts import render, redirect import requests @@ -46,7 +48,10 @@ class AllThreadsView(PostMixin, BaseBoar settings.THREADS_PER_PAGE) paginator.current_page = int(page) - threads = paginator.page(page).object_list + try: + threads = paginator.page(page).object_list + except EmptyPage: + raise Http404() params[PARAMETER_THREADS] = threads params[CONTEXT_FORM] = form