On 24-Apr-08, at 11:47 AM, Kevin L wrote:

> Hello Django users, I'm having trouble with an exclude statement and
> was hoping some kind soul could help me out. My models are simple,
> it's basically just two models with a ForeignKey relationship.
>
> class Parent(models.Model):
>   pass
> class Child(models.Model):
>   name = models.CharField(maxlength=100)
>   parent = models.ForeignKey(Parent)
>
> I want to get every parent who does not have a child named "Bob". I
> initially thought this would just be one exclude statement -
>
> Parent.objects.exclude(child__name="Bob")[:100]

Parent.objects.extra(where=["""id not in (select parent_id from  
app_child where name='bob')"""])

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to