Op maandag 18 juli 2011 20:29:17 UTC+1 schreef kooliah het volgende: > > I need to render a nested queryset in a template, a classic father/son > structure like > publisher>dvds>renters, > > <snip> > in python code i can use this code: > > code > > ------------------------------------------------------------------------------- > pub= publisher.objects.get(publisherid=1) > for disk in pub.dvds_set.all(): > print disk.dvdsname > for rent in disk.renters_set.all(): > print rent.rentersname > > ------------------------------------------------------------------------------- > > How can i do same things in a template ? > Can i call methods in a tag or i have to build a dictionary and pass it > to template? > > Thanks to all >
You can do exactly that, except without the () brackets. You'll need to pass the `pub` object into the template context, but the for loops work fine within the template. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Bm0QDiljOakJ. 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.