视图
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似乎不喜欢模板中的()
在Django站点上有一个迷宫般的信息,我在.96、1.0和dev版本之间一直迷路.我正在运行Django版本1.0.2