我正在和stacey一起工作(https://github.com/kolber/stacey)--the没有花哨的东西,没有数据库组合cms。有人知道为什么下面的模板代码在我的default.html模板中不起作用吗?我知道图像不会以这种方式显示,但我甚至不能让图像名称显示在我的默认页面中。
{% for child in page.root %}
{% if child.children %}
{% for child in child.children %}
<div class="item">
{{ child.title }} - {{ child.type }}
{% for image in child.image %}
{{ image.name }}
{% endfor %}
</div>
{% endif %}
{% endfor %}image.name现在不会向模板返回任何内容。
发布于 2013-08-08 08:31:27
这被证明是一个非常简单的问题。子页面(取决于上下文)中的资源(如图像)数组是复数。上面的代码应该是:
{% for image in child.images %}就这样!
https://stackoverflow.com/questions/18112510
复制相似问题