On 5 jan, 18:09, "alex.gay...@gmail.com" <alex.gay...@gmail.com>
wrote:
> You need to build up the Q object and then filter on it so:
> results = RelatedModel.objects.all()
> q = Q()
> for category in category_list:
> q |= Q(categories__slug = category.slug)
> results = results.filter(q)
Or create a sequence of Q objects and apply reduce on it
from operator import or_
queries = (Q(category__slug=c.slug) for c in category_list)
results = RelatedModel.objects.filter(reduce(or_, queries))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---