On Wed, Jan 7, 2009 at 8:26 PM, Mark Jones <mark0...@gmail.com> wrote:

>
> Ok, here is some simple code:
>
> class Maker(models.Model):
>    name = CharField(max_length=20)
>
> class Auto(models.Model):
>    name = CharField(max_length)
>    maker = ForeignKey(Maker)
>
>
> maker = Maker.objects.get(pk=1)
>
> How do I get all the Autos made by this maker
>
> I don't see a maker.autos (railsish)
> All I have been able to figure out for this is:
>
> Auto.objects.filter(maker=maker.id)    # this works
> Auto.objects.filter(maker=maker)        # this works too
>
> Is that all there is, or is there some maker.autos abstraction that I
> just don't see.  The last method 2 methods both work, but it seems
> awkward to use them given the fact that I have a Maker, and the
> relationship between Maker and Auto is known in the models but via the
> Manager interface requires restatement in (maker=maker.id) or
> alternately (maker=maker)


http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

Karen

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to