From bab9129ff8edbab308d6715112fd20de439ae112 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 24 Aug 2026 06:46:20 -0700 Subject: [PATCH] Fix: lazy import guardian modules to fix search language setting (#13768) Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com> --- src/documents/search/_backend.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/documents/search/_backend.py b/src/documents/search/_backend.py index 8aaa6cccd..b783cfd2d 100644 --- a/src/documents/search/_backend.py +++ b/src/documents/search/_backend.py @@ -20,10 +20,7 @@ from typing import cast import filelock import tantivy from django.conf import settings -from django.contrib.contenttypes.models import ContentType from django.utils.timezone import get_current_timezone -from guardian.shortcuts import get_groups_with_perms -from guardian.shortcuts import get_users_with_perms from documents.search._query import build_permission_filter from documents.search._query import extract_cjk_text @@ -429,6 +426,9 @@ class TantivyBackend: Annotate the queryset with ``annotate_effective_content`` when indexing more than a couple of documents, to resolve that without a query each. """ + from guardian.shortcuts import get_groups_with_perms + from guardian.shortcuts import get_users_with_perms + content = document.get_effective_content() or "" doc = tantivy.Document() @@ -1082,6 +1082,7 @@ def _bulk_get_viewer_permissions( """ from collections import defaultdict + from django.contrib.contenttypes.models import ContentType from guardian.models import GroupObjectPermission from guardian.models import UserObjectPermission