[Fixed]-Construct Django Query with dynamic complex AND + OR structure

1👍

I figured it out with a bit of tinkering:

    qs = self.MyField.all()
    q = Q()

    for combination in my_tuples:
        q = q | Q(Q(language=combination['language']) & Q(country=combination['country']))

    return qs.filter(q)

Leave a comment