Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to dinamically create the Q query in django

tags = ['tag1', 'tag2', 'tag3']
q_objects = Q() # Create an empty Q object to start with
for t in tags:
    q_objects |= Q(tags__tag__contains=t) # 'or' the Q objects together

designs = Design.objects.filter(q_objects)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dinamically #create #Q #query #django
ADD COMMENT
Topic
Name
5+3 =