> class Blah(models.Model):
> ...
> sources = models.ManyToManyField(Source)
>
> The query I want to perform is to find all the Blahs that come from
> sources 1 or 2 but not sources 3 or 4.
What if Blah comes from both 1 and 3?
> The SQL I want to run is something like:
>
> SELECT blah_id
> FROM myapp_blah_sources
> WHERE source_id IN (1, 2)
> EXCEPT
> SELECT blah_id
> FROM myapp_blah_sources
> WHERE source_id in (3, 4);
Isn't this same as:
SELECT blah_id
FROM myapp_blah_sources
WHERE source_id IN (1, 2)
AND source_id NOT IN (3,4)
Maybe "Complex lookups with Q objects" from
http://www.djangoproject.com/documentation/db-api/
can help here or just use extra like:
Blah.objects.extra(where=['source_id IN (1, 2)', 'source_id NOT IN (3,
4)'])
--
Maciej Wisniowski
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---