From 93030852b56b946c83f68f220403e83348f33dec Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 1 Aug 2022 21:23:55 +0100 Subject: [PATCH] Do search if querystring is provided --- website/search/models.py | 1 + website/search/templates/search/search_page.html | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/website/search/models.py b/website/search/models.py index c92df32..a2e9dbc 100644 --- a/website/search/models.py +++ b/website/search/models.py @@ -43,6 +43,7 @@ class SearchPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: ignore def get_context(self, request: HttpRequest) -> dict: context = super().get_context(request) + context["search_query"] = request.GET.get("q", "") context["search_url"] = self.reverse_subpage("results") return context diff --git a/website/search/templates/search/search_page.html b/website/search/templates/search/search_page.html index 67bd270..9908024 100644 --- a/website/search/templates/search/search_page.html +++ b/website/search/templates/search/search_page.html @@ -16,9 +16,10 @@ name="q" placeholder="Search" hx-get="{{ search_url }}" - hx-trigger="keyup changed delay:300ms, search" + hx-trigger="keyup changed delay:300ms, search, revealed" hx-target="#search-results" autocomplete="off" + value="{{ search_query }}" >