Re: Traversing a backward relationship

2008-05-07 Thread Michael J
Eric/r.tirrell, That worked like a charm. Thanks a bunch! However, I did have to add distinct() at the very end of the call, otherwise, I was getting back as many duplicates of a City as there were Jobs in that city. Any reason why? On May 7, 9:10 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> w

Re: Traversing a backward relationship

2008-05-07 Thread [EMAIL PROTECTED]
As far as I know, that's fine. Michael J. could use City.objects.exclude(jobs_isnull=True) to accomplish what he seemed to be going for. On May 7, 2:09 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote: > I've been using something like: > > City.objects.filter(jobs__isnull=True) > > It seems to work,

Re: Traversing a backward relationship

2008-05-06 Thread Eric Abrahamsen
I've been using something like: City.objects.filter(jobs__isnull=True) It seems to work, but I'd really like to know if this is undesirable for any reason. On May 6, 2008, at 8:05 PM, Dmitriy Kurilov wrote: > > Hi. > > # models > > class City(models.Model): ># Fields... > > class Job(mo

Re: Traversing a backward relationship

2008-05-06 Thread Dmitriy Kurilov
Hi. # models class City(models.Model): # Fields... class Job(models.Model): city = models.ForeignKey(City, related_name="jobs") # Other fields # views City.objects.filter(jobs__pk__gt=0) Is it? -Original Message- From: Michael J <[EMAIL PROTECTED]> To: Django users Dat