You forgot a ")" sign. That's why syntax error. On Thu, 2009-10-08 at 23:48 -0700, Eva Hamilton wrote: > >From the django documentation (here: > >http://www.djangoproject.com/documentation/models/select_related/) > I obtained this bit of code for performing a select_related on a list > of objects and producing a list of related objects... > > >>> world = Species.objects.all().select_related() > >>> [o.genus.family for o in world] > [<Family: Drosophilidae>, <Family: Hominidae>, <Family: Fabaceae>, > <Family: Amanitacae>] > > > It works perfectly in the python shell, but I'm wondering what the > correct syntax would be to achieve the same result in a django view? > ie. define a variable that will produce the list of related objects > and can then be used in a template. > > I've tried: > > world = Species.objects.all(select_related() > family_list = [o.genus.family for o in world] > > but get a "syntax error" message. > > Can anyone help? Thanks! > > >
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---