From 7cd93e70f27ba97cfc7cb95bd324ee2ebd0bac15 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Tue, 10 Dec 2024 16:07:50 +0100 Subject: [PATCH] fix(relations): only filter queryset if there is actually a value --- apis_core/relations/filtersets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apis_core/relations/filtersets.py b/apis_core/relations/filtersets.py index f667a5e9a..e545d20eb 100644 --- a/apis_core/relations/filtersets.py +++ b/apis_core/relations/filtersets.py @@ -30,8 +30,10 @@ def _search_all_entities(self, value) -> list[str]: return RootObject.objects_inheritance.filter(q).values_list("pk", flat=True) def filter(self, qs, value): - all_entities = self._search_all_entities(value) - return qs.filter(**{f"{self.field_name}_object_id__in": all_entities}) + if value: + all_entities = self._search_all_entities(value) + return qs.filter(**{f"{self.field_name}_object_id__in": all_entities}) + return qs class SubjObjClassFilter(MultipleChoiceFilter):