Skip to content

Commit 898b2e8

Browse files
cvipulcodingjoe
authored andcommitted
Fix applegrew#418 –– Remove extra Q created in the ORM query (applegrew#548)
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}))
1 parent 1e4056b commit 898b2e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

django_select2/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def filter_queryset(self, request, term, queryset=None, **dependent_fields):
391391
term = term.replace('\t', ' ')
392392
term = term.replace('\n', ' ')
393393
for t in [t for t in term.split(' ') if not t == '']:
394-
select &= reduce(lambda x, y: x | Q(**{y: t}), search_fields,
394+
select &= reduce(lambda x, y: x | Q(**{y: t}), search_fields[1:],
395395
Q(**{search_fields[0]: t}))
396396
if dependent_fields:
397397
select &= Q(**dependent_fields)

0 commit comments

Comments
 (0)