Re: union and intersection of querysets

2006-07-05 Thread Malcolm Tredinnick
On Thu, 2006-07-06 at 02:55 +, Lorin Hochstein wrote: > Malcolm Tredinnick wrote: > > On Wed, 2006-07-05 at 21:38 +, Lorin Hochstein wrote: > > > > One of these (all hypotheses related to any topic on the list) is easy: > > > > Hypothesis.objects.filter(topics__in = topics) > > >

Re: union and intersection of querysets

2006-07-05 Thread Lorin Hochstein
Malcolm Tredinnick wrote: > On Wed, 2006-07-05 at 21:38 +, Lorin Hochstein wrote: > > One of these (all hypotheses related to any topic on the list) is easy: > > Hypothesis.objects.filter(topics__in = topics) > Ah, nice and simple... Somehow I manage to miss that in the docs.

Re: union and intersection of querysets

2006-07-05 Thread Russell Keith-Magee
On 7/6/06, Lorin Hochstein <[EMAIL PROTECTED]> wrote: I realize I can do this using Python sets on the id's, but is there away to do it more efficiently using the database API?At present - not really. Malcolm has pretty much covered the currently available options. However, I would point out that

union and intersection of querysets

2006-07-05 Thread Lorin Hochstein
Hi, I had a question about the database API. I have two models, Hypothesis and Topic, with a many-to-many relationship. Given a list of topics, what I want to do is retrieve the union of related hypotheses (all hypotheses that are associated with any topic in the list) and the intersection of