diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d7d332ea56..0e2ce27e68 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -10,6 +10,7 @@ Changelog * Fix: Ensure that the legacy dropdown options, when closed, do not get accidentally clicked by other interactions wide viewports (CheesyPhoenix, Christer Jensen) * Fix: Add a fallback background for the editing preview iframe for sites without a background (Ian Price) * Fix: Preserve whitespace in rendered comments (Elhussein Almasri) + * Fix: Remove search logging from project template so that new projects without the search promotions module will not error (Matt Westcott) * Docs: Document, for contributors, the use of translate string literals passed as arguments to tags and filters using `_()` within templates (Chiemezuo Akujobi) * Maintenance: Update BeautifulSoup upper bound to 4.12.x (scott-8) * Maintenance: Migrate initialization of classes (such as `body.ready`) from multiple JavaScript implementations to one Stimulus controller `w-init` (Chiemezuo Akujobi) diff --git a/docs/releases/6.0.md b/docs/releases/6.0.md index c8bf25c97d..bd44df9a7b 100644 --- a/docs/releases/6.0.md +++ b/docs/releases/6.0.md @@ -23,6 +23,7 @@ depth: 1 * Ensure that the legacy dropdown options, when closed, do not get accidentally clicked by other interactions wide viewports (CheesyPhoenix, Christer Jensen) * Add a fallback background for the editing preview iframe for sites without a background (Ian Price) * Preserve whitespace in rendered comments (Elhussein Almasri) + * Remove search logging from project template so that new projects without the search promotions module will not error (Matt Westcott) ### Documentation diff --git a/wagtail/project_template/search/views.py b/wagtail/project_template/search/views.py index 703c4dd827..678bb7e87a 100644 --- a/wagtail/project_template/search/views.py +++ b/wagtail/project_template/search/views.py @@ -2,7 +2,13 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.template.response import TemplateResponse from wagtail.models import Page -from wagtail.search.models import Query + +# To enable logging of search queries for use with the "Promoted search results" module +# +# uncomment the following line and the lines indicated in the search function +# (after adding wagtail.contrib.search_promotions to INSTALLED_APPS): + +# from wagtail.contrib.search_promotions.models import Query def search(request): @@ -12,10 +18,12 @@ def search(request): # Search if search_query: search_results = Page.objects.live().search(search_query) - query = Query.get(search_query) - # Record hit - query.add_hit() + # To log this query for use with the "Promoted search results" module: + + # query = Query.get(search_query) + # query.add_hit() + else: search_results = Page.objects.none()