Re: Combining Querysets from different, but similar models

2011-10-05 Thread Brett Epps
I had a similar need and solved it with a separate table of activity feed items. Here's the code for the Item model: class Item(models.Model): object_id = models.PositiveIntegerField(db_index=True) content_type = models.ForeignKey(ContentType) content_object = generic

Re: Combining Querysets from different, but similar models

2011-10-05 Thread Javier Guerra Giraldez
On Wed, Oct 5, 2011 at 8:37 AM, Steven Smith 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 imp

Combining Querysets from different, but similar models

2011-10-05 Thread Steven Smith
I'm working on a site that has a requirement for a "recent activity" feed on the homepage. Usually, I'd just do a MyFoo.objects.order_by('- created') and all would be well. But "activity" is actually from several models. They all have some fields in common, like the timestamp, since they all have t