From e3371233b5e56c38264442c8559ffe6eeba616d3 Mon Sep 17 00:00:00 2001 From: Daoud Clarke Date: Sun, 5 Nov 2023 21:52:09 +0000 Subject: [PATCH] Use replace header instead of push --- mwmbl/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mwmbl/views.py b/mwmbl/views.py index 0f1e5a8..f030c0c 100644 --- a/mwmbl/views.py +++ b/mwmbl/views.py @@ -49,13 +49,15 @@ def profile(request): def search_results(request): query = request.GET["query"] results = ranker.search(query) - rendered = render(request, "results.html", {"results": results, "query": query}) + response = render(request, "results.html", {"results": results, "query": query}) current_url = request.htmx.current_url # Replace query string with new query stripped_url = current_url[:current_url.index("?")] if "?" in current_url else current_url query_string = "?q=" + query if len(query) > 0 else "" new_url = stripped_url + query_string - return push_url(rendered, new_url) + # Set the htmx replace header + response["HX-Replace-Url"] = new_url + return response def fetch_url(request):