prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Searching images without match is not displayed correctly (minor)
  When searching for images, if you enter a query string which will not return resuls you will get the message Sorry, no images match "" (without the query string inside the ""). Beyon this, search works fine.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wagtail/wagtailsearch/views/editorspicks.py`
  Content:
  ```
  1 from django.shortcuts import render, redirect, get_object_or_404
  2 from django.contrib.auth.decorators import permission_required
  3 from django.contrib import messages
  4 
  5 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
  6 from django.utils.translation import ugettext as _
  7 from django.views.decorators.vary import vary_on_headers
  8 
  9 from wagtail.wagtailsearch import models, forms
  10 from wagtail.wagtailadmin.forms import SearchForm
  11 
  12 
  13 @permission_required('wagtailadmin.access_admin')
  14 @vary_on_headers('X-Requested-With')
  15 def index(request):
  16     page = request.GET.get('p', 1)
  17     query_string = request.GET.get('q', "")
  18 
  19     queries = models.Query.objects.filter(editors_picks__isnull=False).distinct()
  20 
  21     # Search
  22     if query_string:
  23         queries = queries.filter(query_string__icontains=query_string)
  24 
  25     # Pagination
  26     paginator = Paginator(queries, 20)
  27     try:
  28         queries = paginator.page(page)
  29     except PageNotAnInteger:
  30         queries = paginator.page(1)
  31     except EmptyPage:
  32         queries = paginator.page(paginator.num_pages)
  33 
  34     if request.is_ajax():
  35         return render(request, "wagtailsearch/editorspicks/results.html", {
  36             'queries': queries,
  37             'query_string': query_string,
  38         })
  39     else:
  40         return render(request, 'wagtailsearch/editorspicks/index.html', {
  41             'queries': queries,
  42             'query_string': query_string,
  43             'search_form': SearchForm(data=dict(q=query_string) if query_string else None, placeholder=_("Search editor's picks")),
  44         })
  45 
  46 
  47 def save_editorspicks(query, new_query, editors_pick_formset):
  48     # Save
  49     if editors_pick_formset.is_valid():
  50         # Set sort_order
  51         for i, form in enumerate(editors_pick_formset.ordered_forms):
  52             form.instance.sort_order = i
  53 
  54         editors_pick_formset.save()
  55 
  56         # If query was changed, move all editors picks to the new query
  57         if query != new_query:
  58             editors_pick_formset.get_queryset().update(query=new_query)
  59 
  60         return True
  61     else:
  62         return False
  63 
  64 
  65 @permission_required('wagtailadmin.access_admin')
  66 def add(request):
  67     if request.POST:
  68         # Get query
  69         query_form = forms.QueryForm(request.POST)
  70         if query_form.is_valid():
  71             query = models.Query.get(query_form['query_string'].value())
  72 
  73             # Save editors picks
  74             editors_pick_formset = forms.EditorsPickFormSet(request.POST, instance=query)
  75             if save_editorspicks(query, query, editors_pick_formset):
  76                 messages.success(request, _("Editor's picks for '{0}' created.").format(query))
  77                 return redirect('wagtailsearch_editorspicks_index')
  78             else:
  79                 if len(editors_pick_formset.non_form_errors()):
  80                     messages.error(request, " ".join(error for error in editors_pick_formset.non_form_errors()))  # formset level error (e.g. no forms submitted)
  81                 else:
  82                     messages.error(request, _("Recommendations have not been created due to errors"))  # specific errors will be displayed within form fields
  83         else:
  84             editors_pick_formset = forms.EditorsPickFormSet()
  85     else:
  86         query_form = forms.QueryForm()
  87         editors_pick_formset = forms.EditorsPickFormSet()
  88 
  89     return render(request, 'wagtailsearch/editorspicks/add.html', {
  90         'query_form': query_form,
  91         'editors_pick_formset': editors_pick_formset,
  92     })
  93 
  94 
  95 @permission_required('wagtailadmin.access_admin')
  96 def edit(request, query_id):
  97     query = get_object_or_404(models.Query, id=query_id)
  98 
  99     if request.POST:
  100         # Get query
  101         query_form = forms.QueryForm(request.POST)
  102         # and the recommendations
  103         editors_pick_formset = forms.EditorsPickFormSet(request.POST, instance=query)
  104 
  105         if query_form.is_valid():
  106             new_query = models.Query.get(query_form['query_string'].value())
  107 
  108             # Save editors picks
  109             if save_editorspicks(query, new_query, editors_pick_formset):
  110                 messages.success(request, _("Editor's picks for '{0}' updated.").format(new_query))
  111                 return redirect('wagtailsearch_editorspicks_index')
  112             else:
  113                 if len(editors_pick_formset.non_form_errors()):
  114                     messages.error(request, " ".join(error for error in editors_pick_formset.non_form_errors()))  # formset level error (e.g. no forms submitted)
  115                 else:
  116                     messages.error(request, _("Recommendations have not been saved due to errors"))  # specific errors will be displayed within form fields
  117 
  118     else:
  119         query_form = forms.QueryForm(initial=dict(query_string=query.query_string))
  120         editors_pick_formset = forms.EditorsPickFormSet(instance=query)
  121 
  122     return render(request, 'wagtailsearch/editorspicks/edit.html', {
  123         'query_form': query_form,
  124         'editors_pick_formset': editors_pick_formset,
  125         'query': query,
  126     })
  127 
  128 
  129 @permission_required('wagtailadmin.access_admin')
  130 def delete(request, query_id):
  131     query = get_object_or_404(models.Query, id=query_id)
  132 
  133     if request.POST:
  134         query.editors_picks.all().delete()
  135         messages.success(request, _("Editor's picks deleted."))
  136         return redirect('wagtailsearch_editorspicks_index')
  137 
  138     return render(request, 'wagtailsearch/editorspicks/confirm_delete.html', {
  139         'query': query,
  140     })
  141
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/wagtail/wagtailsearch/views/editorspicks.py b/wagtail/wagtailsearch/views/editorspicks.py
  --- a/wagtail/wagtailsearch/views/editorspicks.py
  +++ b/wagtail/wagtailsearch/views/editorspicks.py
  @@ -13,6 +13,7 @@
   @permission_required('wagtailadmin.access_admin')
   @vary_on_headers('X-Requested-With')
   def index(request):
  +    is_searching = False
       page = request.GET.get('p', 1)
       query_string = request.GET.get('q', "")
   
  @@ -21,6 +22,7 @@
       # Search
       if query_string:
           queries = queries.filter(query_string__icontains=query_string)
  +        is_searching = True
   
       # Pagination
       paginator = Paginator(queries, 20)
  @@ -33,11 +35,13 @@
   
       if request.is_ajax():
           return render(request, "wagtailsearch/editorspicks/results.html", {
  +            'is_searching': is_searching,
               'queries': queries,
               'query_string': query_string,
           })
       else:
           return render(request, 'wagtailsearch/editorspicks/index.html', {
  +            'is_searching': is_searching,
               'queries': queries,
               'query_string': query_string,
               'search_form': SearchForm(data=dict(q=query_string) if query_string else None, placeholder=_("Search editor's picks")),
  
verification_info: {"golden_diff": "diff --git a/wagtail/wagtailsearch/views/editorspicks.py b/wagtail/wagtailsearch/views/editorspicks.py\n--- a/wagtail/wagtailsearch/views/editorspicks.py\n+++ b/wagtail/wagtailsearch/views/editorspicks.py\n@@ -13,6 +13,7 @@\n @permission_required('wagtailadmin.access_admin')\n @vary_on_headers('X-Requested-With')\n def index(request):\n+    is_searching = False\n     page = request.GET.get('p', 1)\n     query_string = request.GET.get('q', \"\")\n \n@@ -21,6 +22,7 @@\n     # Search\n     if query_string:\n         queries = queries.filter(query_string__icontains=query_string)\n+        is_searching = True\n \n     # Pagination\n     paginator = Paginator(queries, 20)\n@@ -33,11 +35,13 @@\n \n     if request.is_ajax():\n         return render(request, \"wagtailsearch/editorspicks/results.html\", {\n+            'is_searching': is_searching,\n             'queries': queries,\n             'query_string': query_string,\n         })\n     else:\n         return render(request, 'wagtailsearch/editorspicks/index.html', {\n+            'is_searching': is_searching,\n             'queries': queries,\n             'query_string': query_string,\n             'search_form': SearchForm(data=dict(q=query_string) if query_string else None, placeholder=_(\"Search editor's picks\")),\n", "issue": "Searching images without match is not displayed correctly (minor)\nWhen searching for images, if you enter a query string which will not return resuls you will get the message Sorry, no images match \"\" (without the query string inside the \"\"). Beyon this, search works fine.\n\n", "before_files": [{"content": "from django.shortcuts import render, redirect, get_object_or_404\nfrom django.contrib.auth.decorators import permission_required\nfrom django.contrib import messages\n\nfrom django.core.paginator import Paginator, EmptyPage, PageNotAnInteger\nfrom django.utils.translation import ugettext as _\nfrom django.views.decorators.vary import vary_on_headers\n\nfrom wagtail.wagtailsearch import models, forms\nfrom wagtail.wagtailadmin.forms import SearchForm\n\n\n@permission_required('wagtailadmin.access_admin')\n@vary_on_headers('X-Requested-With')\ndef index(request):\n    page = request.GET.get('p', 1)\n    query_string = request.GET.get('q', \"\")\n\n    queries = models.Query.objects.filter(editors_picks__isnull=False).distinct()\n\n    # Search\n    if query_string:\n        queries = queries.filter(query_string__icontains=query_string)\n\n    # Pagination\n    paginator = Paginator(queries, 20)\n    try:\n        queries = paginator.page(page)\n    except PageNotAnInteger:\n        queries = paginator.page(1)\n    except EmptyPage:\n        queries = paginator.page(paginator.num_pages)\n\n    if request.is_ajax():\n        return render(request, \"wagtailsearch/editorspicks/results.html\", {\n            'queries': queries,\n            'query_string': query_string,\n        })\n    else:\n        return render(request, 'wagtailsearch/editorspicks/index.html', {\n            'queries': queries,\n            'query_string': query_string,\n            'search_form': SearchForm(data=dict(q=query_string) if query_string else None, placeholder=_(\"Search editor's picks\")),\n        })\n\n\ndef save_editorspicks(query, new_query, editors_pick_formset):\n    # Save\n    if editors_pick_formset.is_valid():\n        # Set sort_order\n        for i, form in enumerate(editors_pick_formset.ordered_forms):\n            form.instance.sort_order = i\n\n        editors_pick_formset.save()\n\n        # If query was changed, move all editors picks to the new query\n        if query != new_query:\n            editors_pick_formset.get_queryset().update(query=new_query)\n\n        return True\n    else:\n        return False\n\n\n@permission_required('wagtailadmin.access_admin')\ndef add(request):\n    if request.POST:\n        # Get query\n        query_form = forms.QueryForm(request.POST)\n        if query_form.is_valid():\n            query = models.Query.get(query_form['query_string'].value())\n\n            # Save editors picks\n            editors_pick_formset = forms.EditorsPickFormSet(request.POST, instance=query)\n            if save_editorspicks(query, query, editors_pick_formset):\n                messages.success(request, _(\"Editor's picks for '{0}' created.\").format(query))\n                return redirect('wagtailsearch_editorspicks_index')\n            else:\n                if len(editors_pick_formset.non_form_errors()):\n                    messages.error(request, \" \".join(error for error in editors_pick_formset.non_form_errors()))  # formset level error (e.g. no forms submitted)\n                else:\n                    messages.error(request, _(\"Recommendations have not been created due to errors\"))  # specific errors will be displayed within form fields\n        else:\n            editors_pick_formset = forms.EditorsPickFormSet()\n    else:\n        query_form = forms.QueryForm()\n        editors_pick_formset = forms.EditorsPickFormSet()\n\n    return render(request, 'wagtailsearch/editorspicks/add.html', {\n        'query_form': query_form,\n        'editors_pick_formset': editors_pick_formset,\n    })\n\n\n@permission_required('wagtailadmin.access_admin')\ndef edit(request, query_id):\n    query = get_object_or_404(models.Query, id=query_id)\n\n    if request.POST:\n        # Get query\n        query_form = forms.QueryForm(request.POST)\n        # and the recommendations\n        editors_pick_formset = forms.EditorsPickFormSet(request.POST, instance=query)\n\n        if query_form.is_valid():\n            new_query = models.Query.get(query_form['query_string'].value())\n\n            # Save editors picks\n            if save_editorspicks(query, new_query, editors_pick_formset):\n                messages.success(request, _(\"Editor's picks for '{0}' updated.\").format(new_query))\n                return redirect('wagtailsearch_editorspicks_index')\n            else:\n                if len(editors_pick_formset.non_form_errors()):\n                    messages.error(request, \" \".join(error for error in editors_pick_formset.non_form_errors()))  # formset level error (e.g. no forms submitted)\n                else:\n                    messages.error(request, _(\"Recommendations have not been saved due to errors\"))  # specific errors will be displayed within form fields\n\n    else:\n        query_form = forms.QueryForm(initial=dict(query_string=query.query_string))\n        editors_pick_formset = forms.EditorsPickFormSet(instance=query)\n\n    return render(request, 'wagtailsearch/editorspicks/edit.html', {\n        'query_form': query_form,\n        'editors_pick_formset': editors_pick_formset,\n        'query': query,\n    })\n\n\n@permission_required('wagtailadmin.access_admin')\ndef delete(request, query_id):\n    query = get_object_or_404(models.Query, id=query_id)\n\n    if request.POST:\n        query.editors_picks.all().delete()\n        messages.success(request, _(\"Editor's picks deleted.\"))\n        return redirect('wagtailsearch_editorspicks_index')\n\n    return render(request, 'wagtailsearch/editorspicks/confirm_delete.html', {\n        'query': query,\n    })\n", "path": "wagtail/wagtailsearch/views/editorspicks.py"}], "after_files": [{"content": "from django.shortcuts import render, redirect, get_object_or_404\nfrom django.contrib.auth.decorators import permission_required\nfrom django.contrib import messages\n\nfrom django.core.paginator import Paginator, EmptyPage, PageNotAnInteger\nfrom django.utils.translation import ugettext as _\nfrom django.views.decorators.vary import vary_on_headers\n\nfrom wagtail.wagtailsearch import models, forms\nfrom wagtail.wagtailadmin.forms import SearchForm\n\n\n@permission_required('wagtailadmin.access_admin')\n@vary_on_headers('X-Requested-With')\ndef index(request):\n    is_searching = False\n    page = request.GET.get('p', 1)\n    query_string = request.GET.get('q', \"\")\n\n    queries = models.Query.objects.filter(editors_picks__isnull=False).distinct()\n\n    # Search\n    if query_string:\n        queries = queries.filter(query_string__icontains=query_string)\n        is_searching = True\n\n    # Pagination\n    paginator = Paginator(queries, 20)\n    try:\n        queries = paginator.page(page)\n    except PageNotAnInteger:\n        queries = paginator.page(1)\n    except EmptyPage:\n        queries = paginator.page(paginator.num_pages)\n\n    if request.is_ajax():\n        return render(request, \"wagtailsearch/editorspicks/results.html\", {\n            'is_searching': is_searching,\n            'queries': queries,\n            'query_string': query_string,\n        })\n    else:\n        return render(request, 'wagtailsearch/editorspicks/index.html', {\n            'is_searching': is_searching,\n            'queries': queries,\n            'query_string': query_string,\n            'search_form': SearchForm(data=dict(q=query_string) if query_string else None, placeholder=_(\"Search editor's picks\")),\n        })\n\n\ndef save_editorspicks(query, new_query, editors_pick_formset):\n    # Save\n    if editors_pick_formset.is_valid():\n        # Set sort_order\n        for i, form in enumerate(editors_pick_formset.ordered_forms):\n            form.instance.sort_order = i\n\n        editors_pick_formset.save()\n\n        # If query was changed, move all editors picks to the new query\n        if query != new_query:\n            editors_pick_formset.get_queryset().update(query=new_query)\n\n        return True\n    else:\n        return False\n\n\n@permission_required('wagtailadmin.access_admin')\ndef add(request):\n    if request.POST:\n        # Get query\n        query_form = forms.QueryForm(request.POST)\n        if query_form.is_valid():\n            query = models.Query.get(query_form['query_string'].value())\n\n            # Save editors picks\n            editors_pick_formset = forms.EditorsPickFormSet(request.POST, instance=query)\n            if save_editorspicks(query, query, editors_pick_formset):\n                messages.success(request, _(\"Editor's picks for '{0}' created.\").format(query))\n                return redirect('wagtailsearch_editorspicks_index')\n            else:\n                if len(editors_pick_formset.non_form_errors()):\n                    messages.error(request, \" \".join(error for error in editors_pick_formset.non_form_errors()))  # formset level error (e.g. no forms submitted)\n                else:\n                    messages.error(request, _(\"Recommendations have not been created due to errors\"))  # specific errors will be displayed within form fields\n        else:\n            editors_pick_formset = forms.EditorsPickFormSet()\n    else:\n        query_form = forms.QueryForm()\n        editors_pick_formset = forms.EditorsPickFormSet()\n\n    return render(request, 'wagtailsearch/editorspicks/add.html', {\n        'query_form': query_form,\n        'editors_pick_formset': editors_pick_formset,\n    })\n\n\n@permission_required('wagtailadmin.access_admin')\ndef edit(request, query_id):\n    query = get_object_or_404(models.Query, id=query_id)\n\n    if request.POST:\n        # Get query\n        query_form = forms.QueryForm(request.POST)\n        # and the recommendations\n        editors_pick_formset = forms.EditorsPickFormSet(request.POST, instance=query)\n\n        if query_form.is_valid():\n            new_query = models.Query.get(query_form['query_string'].value())\n\n            # Save editors picks\n            if save_editorspicks(query, new_query, editors_pick_formset):\n                messages.success(request, _(\"Editor's picks for '{0}' updated.\").format(new_query))\n                return redirect('wagtailsearch_editorspicks_index')\n            else:\n                if len(editors_pick_formset.non_form_errors()):\n                    messages.error(request, \" \".join(error for error in editors_pick_formset.non_form_errors()))  # formset level error (e.g. no forms submitted)\n                else:\n                    messages.error(request, _(\"Recommendations have not been saved due to errors\"))  # specific errors will be displayed within form fields\n\n    else:\n        query_form = forms.QueryForm(initial=dict(query_string=query.query_string))\n        editors_pick_formset = forms.EditorsPickFormSet(instance=query)\n\n    return render(request, 'wagtailsearch/editorspicks/edit.html', {\n        'query_form': query_form,\n        'editors_pick_formset': editors_pick_formset,\n        'query': query,\n    })\n\n\n@permission_required('wagtailadmin.access_admin')\ndef delete(request, query_id):\n    query = get_object_or_404(models.Query, id=query_id)\n\n    if request.POST:\n        query.editors_picks.all().delete()\n        messages.success(request, _(\"Editor's picks deleted.\"))\n        return redirect('wagtailsearch_editorspicks_index')\n\n    return render(request, 'wagtailsearch/editorspicks/confirm_delete.html', {\n        'query': query,\n    })\n", "path": "wagtail/wagtailsearch/views/editorspicks.py"}]}