Re: exclude with ForeignKey

2008-04-24 Thread Kenneth Gonsalves
On 24-Apr-08, at 12:48 PM, Kevin L wrote: > Thanks everyone for the responses, I'm very impressed by the quick > response of the community here ;-) if you want extra-fast responses come to #django on freenode -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~

Re: exclude with ForeignKey

2008-04-24 Thread Kevin L
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,

Re: exclude with ForeignKey

2008-04-23 Thread Kenneth Gonsalves
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

Re: exclude with ForeignKey

2008-04-23 Thread Malcolm Tredinnick
On Wed, 2008-04-23 at 23:23 -0700, [EMAIL PROTECTED] wrote: > If you are getting the correct resultset, just with parents multiple > times, add .distinct() to your queryset. It sounded more like the case of a parent having children called Anna and Bob. The parent was still being selected, since

Re: exclude with ForeignKey

2008-04-23 Thread Malcolm Tredinnick
On Wed, 2008-04-23 at 23:17 -0700, Kevin L wrote: [...] > 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] > > However, this gives me a list that includes many p

Re: exclude with ForeignKey

2008-04-23 Thread [EMAIL PROTECTED]
If you are getting the correct resultset, just with parents multiple times, add .distinct() to your queryset. On Apr 24, 1:17 am, Kevin L <[EMAIL PROTECTED]> 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

exclude with ForeignKey

2008-04-23 Thread Kevin L
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=