Thanks! This extra nested query is working, although intuitively it
seems inefficient when combined with a limit. (I'm not an sql expert
though, and in my app it is doing ok for now.)

Thanks everyone for the responses, I'm very impressed by the quick
response of the community here ;-)

On Apr 23, 11:43 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> 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
> kghttp://lawgon.livejournal.comhttp://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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to