Let's say I have the following piece of code:
criteria = {'description': 'tt', 'hostname': '2'}
filters = Q()
{filters.add(Q(**{k+'__icontains': v}), Q.AND) for k,v in criteria.items()}
I can't figure out how to avoid doubling the outcome:
{<Q: (AND: ('description__icontains', 'tt'), ('hostname__icontains', '2'))>,
<Q: (AND: ('description__icontains', 'tt'), ('hostname__icontains', '2'))>}
I understand I should shift Q.AND
somewhere, shouldn't I?