I\'m trying to query a database based on user input tags. The number of tags can be from 0-5, so I need to create the query dynamically.
So I have a tag list, tag_li
You may need to add AND and OR conditions
query = (Q(fild1='ENABLE')) # Filter by list query.add(Q(fild2__in=[p.code for p in Objects.field.all()]), Q.AND) # filter OR q_objects = Q(field3='9999999') for x in myList: q_objects.add(Q(field3=x.code), Q.OR) query.add(q_objects, Q.AND)