0
我的博客模式中选择一个表中鲜明的条目。所以这里是我在我的意见中所做的:基于列的
class CategoriesMainPage(webapp2.RequestHandler):
def get(self):
categories = db.GqlQuery("SELECT distinct category FROM BlogEntry")
print categories.count()
template_values = {
'categories':categories,
}
template = JINJA_ENVIRONMENT.get_template('categories_index.html')
self.response.write(template.render(template_values))
我在迭代模板中的“类别”时出现错误。下面是我得到的错误:
BadValueError: Property title is required
我的模板:
{% for category in categories %}
<div class="col-sm-6 col-md-2 separate-post-item">
<div class="thumbnail">
<div class="caption">
<a href="/category/{{ category.category }}">{{ category.category }}</a>
</div>
</div>
</div>
{% endfor %}
我无法想象任何其他方式来做到这一点。任何帮助?
模板用'categories'做什么? (包括那一点代码。) – Greg