【发布时间】:2010-11-04 02:47:02
【问题描述】:
查看
categories = Category.objects.all()
t = loader.get_template('index.html')
v = Context({
'categories': categories
})
return HttpResponse(t.render(v))
模板
{% for category in categories %}
<h1>{{ category.name }}</h1>
{% endfor %}
这很好用。现在我正在尝试打印该类别中的每家公司。 company 表有一个到 category 表的外键
试过了
{% for company in category.company_set.all() %}
似乎 django 不喜欢模板中的 ()
在 .96、1.0 和开发版本之间,我不断迷失在 django 网站上的信息迷宫。我正在运行 django 版本 1.0.2
【问题讨论】:
标签: python django django-models django-templates