From 3431d2abddd379cb7fa019c9ecb3f631899dff4f Mon Sep 17 00:00:00 2001 From: Tom <145599715+tvanonna@users.noreply.github.com> Date: Thu, 11 Jan 2024 22:08:53 +0100 Subject: [PATCH] Fixed Album Pagination Erasing Search Terms (#3528) * Fix keywords being erased when going to next page in list of albums * Same as the previous commit on this branch, file was missing. * Fix url building --------- Co-authored-by: Ties --- .../templates/paginated_page.html | 34 +++++++++---------- website/thaliawebsite/views.py | 9 +++++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/website/thaliawebsite/templates/paginated_page.html b/website/thaliawebsite/templates/paginated_page.html index 6e5a67110..93a037e63 100644 --- a/website/thaliawebsite/templates/paginated_page.html +++ b/website/thaliawebsite/templates/paginated_page.html @@ -6,28 +6,26 @@ diff --git a/website/thaliawebsite/views.py b/website/thaliawebsite/views.py index 733b67866..0d2516374 100644 --- a/website/thaliawebsite/views.py +++ b/website/thaliawebsite/views.py @@ -31,6 +31,7 @@ class PagedView(ListView): def get_context_data(self, **kwargs) -> dict: context = super().get_context_data(**kwargs) + print(kwargs) page = context["page_obj"].number paginator = context["paginator"] @@ -48,9 +49,17 @@ def get_context_data(self, **kwargs) -> dict: page_range = range(page_range_start, page_range_stop) + querydict = self.request.GET.copy() + + if "page" in querydict: + del querydict["page"] + context.update( { "page_range": page_range, + "base_url": f"{self.request.path}?{querydict.urlencode()}&" + if querydict + else f"{self.request.path}?", } )