【发布时间】:2013-04-26 09:09:14
【问题描述】:
我对给定对象有三个条件,1。开始,2。开始和3。完成。
我过滤视图本身中的对象并将三个变量发送到模板 -
tostart_objects、started_objects 和 finished_objects。
现在我循环遍历html模板中的三个for循环如下:
{% for obj in tostart_objects %}
// chunk of html template to display all the object
{% endfor %}
{% for obj in started_objects %}
// similar chunk of html template as above
{% endfor %}
{% for obj in finished_objects %}
// similar chunk of html template as above
{% endfor %}
我可以不在三个不同的地方重用它们,而不是放置相同的代码块吗? 如何才能做到这一点?请告知,谢谢!
【问题讨论】:
标签: python html django django-templates