Show message when there's no search terms

This commit is contained in:
Jake Howard 2022-07-29 22:34:48 +01:00
parent 71a2186cc0
commit 2ae2a2c158
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 7 additions and 2 deletions

View file

@ -70,6 +70,9 @@ class SearchPage(BaseContentMixin, BasePage): # type: ignore[misc]
context["results"] = results context["results"] = results
else: else:
context["invalid_search"] = True if "q" in request.GET:
context["invalid_search"] = True
else:
context["initial"] = True
return context return context

View file

@ -11,7 +11,9 @@
{% endif %} {% endif %}
<section class="container"> <section class="container">
{% if invalid_search %} {% if initial %}
<p>Enter search terms</p>
{% elif invalid_search %}
<p>Invalid search</p> <p>Invalid search</p>
{% elif results|length == 0 %} {% elif results|length == 0 %}
{% if page_num > paginator.num_pages %} {% if page_num > paginator.num_pages %}