# HG changeset patch # User neko259 # Date 2018-04-07 08:37:33 # Node ID e11ab41b739a0e686f8fc5c484fa79147381cb3d # Parent 188b2da76fe7559f589a0ff17bd85be753b12c6b Display proper page for search and notifications divided paginator diff --git a/boards/views/notifications.py b/boards/views/notifications.py --- a/boards/views/notifications.py +++ b/boards/views/notifications.py @@ -43,6 +43,7 @@ class NotificationView(BaseBoardView, Pa paginator = get_paginator(posts, RESULTS_PER_PAGE, link=reverse('notifications'), params=request.GET.dict()) + paginator.current_page = page params[PARAM_PAGE] = paginator.page(page) params[PARAM_USERNAMES] = notification_usernames diff --git a/boards/views/search.py b/boards/views/search.py --- a/boards/views/search.py +++ b/boards/views/search.py @@ -16,7 +16,6 @@ FORM_QUERY = 'query' CONTEXT_QUERY = 'query' CONTEXT_FORM = 'form' -CONTEXT_PAGE = 'page' CONTEXT_TAGS = 'tags' REQUEST_PAGE = 'page' @@ -36,6 +35,8 @@ class BoardSearchView(View, PaginatedMix if form.is_valid(): query = form.cleaned_data[FORM_QUERY] if len(query) >= MIN_QUERY_LENGTH: + page = int(request.GET.get(REQUEST_PAGE, '1')) + results = Post.objects.filter(Q(text__icontains=query) | Q(title__icontains=query) | Q(opening=True, thread__tags__aliases__name__icontains=query) @@ -43,8 +44,7 @@ class BoardSearchView(View, PaginatedMix paginator = get_paginator(results, RESULTS_PER_PAGE, link=reverse('search'), params=request.GET.dict()) - - page = int(request.GET.get(REQUEST_PAGE, '1')) + paginator.current_page = page params[CONTEXT_QUERY] = query params.update(self.get_page_context(paginator, page))