diff --git a/search/views.py b/search/views.py index a98a2003..dee542f7 100644 --- a/search/views.py +++ b/search/views.py @@ -13,9 +13,18 @@ def search(request: HttpRequest) -> HttpResponse: # Search # Using the 'or' operator to search for pages that contain any of the words if search_query: - search_results = Page.objects.live().search( - search_query, - operator="or", + search_results = ( + Page.objects.live() + .specific() # Get specific page types in single query + .select_related( # Fetch related fields in single query + "owner", + "content_type", + "locale", + ) + .search( + search_query, + operator="or", + ) ) else: search_results = Page.objects.none()