code
-------------------------------------------------------------------------------
class publisher(models.Model):
publisherid = models.IntegerField(primary_key=True)
publishername = models.CharField(max_length=135, blank=True)
class dvds(models.Model):
dvdsid = models.IntegerField(primary_key=True)
dvdsname = models.CharField(max_length=135,verbose_name='Corp.Name')
publisher_publisherid = models.ForeignKey(publisher,
db_column='publisher_publisherid')
class renters(models.Model):
rentersid = models.IntegerField(primary_key=True)
rentersname = models.CharField(max_length=135, blank=True)
dvds_dvdsid = models.ForeignKey(dvds, db_column='dvds_dvdsid')
-------------------------------------------------------------------------------
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
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 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...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.