Answer the question
In order to leave comments, you need to log in
Is it possible to loop through arguments to a function?
Here are the arguments in filter Q(title__icontains=true_fuzzy_list[0]) | Q(title__icontains=true_fuzzy_list[1]) for two elements from an array, how can one add arguments for more elements in an array?
Answer the question
In order to leave comments, you need to log in
from functools import reduce
import operator
from django.db.models import Q
conditions = [Q(title__icontains=i) for i in true_fuzzy_list]
results = Item.objects.filter(reduce(operator.or_, conditions ))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question