On 4/10/06, Russell Cloran <[EMAIL PROTECTED]> wrote:
> I have a model (A) which has a foreign key to another (B). I wish to
> construct a query for all B which have an empty a_set.
>
> This is possible with SQL, using something like:
>
> SELECT b.id FROM b LEFT OUTER JOIN a ON b.id=a.b_id WHERE b.a_id IS
> NULL;
>
> How would I construct such a query using the Django ORM?

That's not possible with the Django ORM, but you can drop into raw SQL
quite easily. See this page for an example:
http://www.djangoproject.com/documentation/models/custom_methods/

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to