diff --git a/core/views/site.py b/core/views/site.py index 8eedcf67..3b75cdde 100644 --- a/core/views/site.py +++ b/core/views/site.py @@ -71,6 +71,8 @@ def notification(request, notif_id): def search_user(query, as_json=False): + if query == "": + return [] res = SearchQuerySet().models(User).autocomplete(auto=query)[:20] return [r.object for r in res] diff --git a/forum/templates/forum/search.jinja b/forum/templates/forum/search.jinja index 4d15714a..fed3803e 100644 --- a/forum/templates/forum/search.jinja +++ b/forum/templates/forum/search.jinja @@ -4,9 +4,9 @@ {% block content %}
+ {{ display_search_bar() }} {% if object_list|length != 0 %}
- {{ display_search_bar() }}
{% for m in object_list %} {{ display_message(m, user) }} diff --git a/forum/views.py b/forum/views.py index 56245752..32dab177 100644 --- a/forum/views.py +++ b/forum/views.py @@ -54,6 +54,8 @@ class ForumSearchView(ListView): def get_queryset(self): query = self.request.GET.get("query", "") + if query == "": + return [] queryset = SearchQuerySet().models(ForumMessage).autocomplete(auto=query)[:100] return [ r.object for r in queryset if can_view(r.object.topic, self.request.user)