From 49a9d03471254b4d3369d7f40ad286296349b3ed Mon Sep 17 00:00:00 2001 From: mipel Date: Wed, 29 Sep 2021 11:44:07 +0200 Subject: [PATCH] #7 New Form * extends KonovaCode filtering for parent objects matching given input --- konova/autocompletes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/konova/autocompletes.py b/konova/autocompletes.py index a75a711a..94798b96 100644 --- a/konova/autocompletes.py +++ b/konova/autocompletes.py @@ -107,7 +107,9 @@ class KonovaCodeAutocomplete(Select2QuerySetView): q_or = Q() q_or |= Q(long_name__icontains=self.q) q_or |= Q(short_name__icontains=self.q) - qs = qs.filter(q_or) + q_or |= Q(parent__long_name__icontains=self.q) + q_or |= Q(parent__short_name__icontains=self.q) + qs = qs.filter(q_or).distinct() return qs