【发布时间】:2014-02-18 05:55:03
【问题描述】:
我的模型是
class Product(models.Model):
name = models.CharField(max_length=50)
desc = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class ProductModels(models.Model):
product = models.ForeignKey(Product)
name = models.CharField(max_length=50)
price = IntegerField(max_length=50)
def __unicode__(self):
return self.name
我可以轻松地在 python 、 product 和它的相关模型中打印,但是在 django 模板中,我无法弄清楚如何打印它们。
我希望在这样的 html 页面中看到数据:
product1 modelpm1
modelpm2
product2 modelpm3
modelpm4
modelpm5
and so on .....
当然,我已经正确创建了表格和所有与 html 相关的标签,但我无法弄清楚如何在模板中以这种方式打印。
【问题讨论】:
标签: python django django-templates django-queryset