Nevermind.  I should have searched a little more.  I found this which
explains it all: http://www.djangoproject.com/documentation/db-api/#backward

I can't wait for my Django programming book to be delivered.

On Jun 13, 2:24 pm, vhg119 <[EMAIL PROTECTED]> wrote:
> To clarify, is there a built in way of doing
>
> manName = "ford"
> m = Manufacturer.objects.filter(name = manName)[0]
> c = m.list_of_cars()
>
> rather than doing another search and filter through Cars?
>
> On Jun 13, 2:20 pm, vhg119 <[EMAIL PROTECTED]> wrote:
>
> > Say I have these two models:
>
> > class Manufacturer(models.Model):
> >      name = models.CharField( maxlength=30)
>
> > class Car(models.Model):
> >     manufacturer = models.ForeignKey(Manufacturer)
> >     name = models.CharField( maxlength=30)
>
> > As you can see, a car is made by one manufacturer.  One manufacturer
> > makes many cars.
>
> > Is there a simpler way to get a list of cars made by a manufacturer
> > given the manufacturer's name?
>
> > I've been doing:
>
> > manName = "ford"
> > m = Manufacturer.objects.filter(name = manName)[0]
> > c = Car.objects.filter(manufacturer = m.id)
>
> > Is there a better way of accomplishing this?
>
> > Vince


--~--~---------~--~----~------------~-------~--~----~
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