1👍
✅
To answer your specific question about stacking or
clauses – in the general case you can combine Q objects using the functional label for |
in the built-in operator
module.
import operator
return_queryset = model_name.objects(filter(reduce(operator.or_,
(Q(Column_name=name) for name in request.POST.getlist('Column_name')))))
But for this specific case I would use in
:
return_queryset = model_name.objects.filter(Column_name__in=request.POST.getlist('Column_name'))
Source:stackexchange.com