On Wed, Oct 5, 2011 at 8:37 AM, Steven Smith <ste...@stevenlsmith.com> wrote: > What's the cheapest way to do my queries and mix the results into one > feed?
I'd say to do it in Python. a simpler case: you have two querysets and want a single 'feed' with results of one query followed by the other: from itertools import chain reviews = Review.objects.filter(....) postings = MarketplacePosting.objects.filter(...) combined_feed = chain(reviews, postings) simple, eh? now a nicest addition would be to define an ordering for each queryset on a similarly-named field and have the resultant combination merges so the order is respected; something like this (untested!): def merge (fld, seqA, seqB): iterA, iterB = iter(seqA), iter(seqB) a, b = next(iterA), next(iterB) while True: if getattr(a,fld) <= getattr(b,fld): yield a try: a = next(iterA) except StopIteration: while True: yield next(iterB) else: yield b b = next(iterB) try: b = next(iterB) except StopIteration: while True: yield next(iterA) -- Javier -- 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.