From 898b2e84dda286026034b0de8c8b13515ff3c87f Mon Sep 17 00:00:00 2001 From: Vipul Chaudhary Date: Mon, 10 Jun 2019 20:27:17 +0530 Subject: [PATCH] =?UTF-8?q?Fix=20#418=20=E2=80=93=E2=80=93=20Remove=20extr?= =?UTF-8?q?a=20Q=20created=20in=20the=20ORM=20query=20(#548)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The iterator for reduce function should not have the first element select &= reduce(lambda x, y: x | Q(**{y: t}), search_fields[1:], Q(**{search_fields[0]: t})) --- django_select2/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_select2/forms.py b/django_select2/forms.py index 75b2956..132d53a 100644 --- a/django_select2/forms.py +++ b/django_select2/forms.py @@ -391,7 +391,7 @@ class ModelSelect2Mixin: term = term.replace('\t', ' ') term = term.replace('\n', ' ') for t in [t for t in term.split(' ') if not t == '']: - select &= reduce(lambda x, y: x | Q(**{y: t}), search_fields, + select &= reduce(lambda x, y: x | Q(**{y: t}), search_fields[1:], Q(**{search_fields[0]: t})) if dependent_fields: select &= Q(**dependent_fields)