Fix #418 –– Remove extra Q created in the ORM query (#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}))
This commit is contained in:
Vipul Chaudhary 2019-06-10 20:27:17 +05:30 committed by Johannes Hoppe
parent 1e4056bd62
commit 898b2e84dd

View file

@ -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)