From 5411207ea79bbffeac155683d5ada24d448c1160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Farka?= <stepanfarka11@gmail.com> Date: Thu, 7 Jul 2022 12:31:26 +0200 Subject: [PATCH] [FIX] fixed ordering pages only for ajax calls --- tuning/wagtail_hooks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tuning/wagtail_hooks.py b/tuning/wagtail_hooks.py index 870f141b..07d7a842 100644 --- a/tuning/wagtail_hooks.py +++ b/tuning/wagtail_hooks.py @@ -1,3 +1,5 @@ +import re + from django.conf import settings from django.contrib.postgres.lookups import Unaccent from django.db.models.functions import Lower @@ -27,7 +29,10 @@ def add_another_welcome_panel(request, panels): @hooks.register("construct_explorer_page_queryset") def show_my_profile_only(parent_page, pages, request): - return pages.order_by(Unaccent(Lower("title"))) + requested_html = re.search(r"^text/html", request.META.get("HTTP_ACCEPT")) + if not requested_html: + return pages.order_by(Unaccent(Lower("title"))) + return pages @hooks.register("insert_global_admin_css") -- GitLab