1👍
from operator import or_
val = MyModel.objects.filter(reduce(or_,(Q(item__startswith=x) for x in searchQuery)))
Use reduce
to combine a generated sequence of Q
expressions.
Source:stackexchange.com
1👍
from operator import or_
val = MyModel.objects.filter(reduce(or_,(Q(item__startswith=x) for x in searchQuery)))
Use reduce
to combine a generated sequence of Q
expressions.