For example, I have 2 querysets:
q1=MyModel.objects.filter(visible=True)
q2=MyModel.objects.filter(published=True)
And i need to make single queryset or list having all objects from q1 and q2.
I used to do it like this:
q=list(chain(q1,q2))
#q= q1 | q2 #this gives me not all objects from q2 or q1,so i don't use bitwise or
But it was said, that list()
will produce extra queries to database. Is it true? And if it is, can somebody specify the most optimized way to do the merge?