Michael, I believe the case of query.select_related(person__place) will "only" follow the place foreign key. This means that if you had 5 FK's in your person models, that only a single FK would be followed instead of all 5 for optimization. Upon further looking there is also a "depth" argument you can pass to select related to specify how far you want it to go. For example:
query.select_related(depth=5) # This will follow all FK's 5 levels deep query.select_ralted('person__place', depth=5) # This will follow only the place FK 5 levels deep That is how I read the docs, it may not be correct :) Cheers, Dan Harris dih0...@gmail.com On Jun 10, 4:54 pm, Michael Hrivnak <mhriv...@americanri.com> wrote: > I read that myself. I asked the question because it goes on to state that you > can specify down-stream models like this: > > query.select_related(person__place) > > If it follows all relationships as far as possible, even when specific > relationships are requested, why would that syntax ever be necessary? We > could just specify "people", and it would follow the "place" relationship > automatically. Is it only to specifically prevent it from following other > relationships on the "person" model? > > The docs seem to be ambiguous on this point. > > Thanks, > Michael > > On Thursday 10 June 2010 03:37:59 pm Dan Harris wrote: > > > > > According to the select_related() documentation at: > >http://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.... > > .QuerySet.select_related > > > it looks like select related "follows foreign keys as far as > > possible". In the documentation example it shows select_related > > following a foreign keys with a depth of two. > > > Hope this helps, > > > Dan Harris > > dih0...@gmail.com > > > On Jun 10, 3:19 pm, Michael Hrivnak <mhriv...@americanri.com> wrote: > > > If I use select_related() on a queryset and specify some attribute names, > > > will it follow those relationships as far as possible, or does that imply > > > "depth=1"? > > > > Thanks, > > > Michael > > > > signature.asc > > > < 1KViewDownload > > > > signature.asc > < 1KViewDownload -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.