From af891dbf1b0bbfd56e4ce107829b8ade41d62d55 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 6 Apr 2024 18:35:28 -0400 Subject: [PATCH] Keep query params on pagination next. --- gameserver/templatetags/search.py | 10 ++++++++++ templates/paginator/snippet.html | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gameserver/templatetags/search.py b/gameserver/templatetags/search.py index 3fc6cb1..4a87fa2 100644 --- a/gameserver/templatetags/search.py +++ b/gameserver/templatetags/search.py @@ -1,6 +1,7 @@ import re from django import template +from django.http import QueryDict from django.shortcuts import resolve_url register = template.Library() @@ -17,3 +18,12 @@ def get_search_page(request): elif match := re.fullmatch(r"^/contest/([^/]+)/scoreboard$", request.path): return resolve_url("contest_scoreboard", slug=match.group(1)) return + + +@register.filter +def format_GET(GET: QueryDict): + GET = GET.copy() + GET.pop("page", None) + if GET.get("nfts", None) == "": + del GET["nfts"] + return GET.urlencode() diff --git a/templates/paginator/snippet.html b/templates/paginator/snippet.html index f69d75b..264dd6c 100644 --- a/templates/paginator/snippet.html +++ b/templates/paginator/snippet.html @@ -1,15 +1,20 @@ +{% load search %} + + {% if page_obj.paginator %} {% endif %} + +