我似乎无法弄清楚为什么我的 feed_image 在调用时可以在页面上工作,{{ self.feed_image }}
但是在尝试添加到索引页面时,它不会显示 - 只是显示损坏的图像。
片段
@register.inclusion_tag(
'tags/_product-snippets.html',
takes_context=True
)
def product_snippets(context, calling_page):
pages = calling_page.get_children().live()
return {
'pages': pages,
# required by the pageurl tag that we want to use within this template
'request': context['request'],
}
标签
<div class="row">
{% for page in pages %}
<div class="col-md-3 col-sm-4 col-xs-12">
<div class="shop-item-container-in">
{% image page.feed_image as img %}
<img src="{{ img.url }}" alt="{{ page.title }}" title="{{ page.title }}" class="img-responsive center-block shop-item-img-list-view"/>
</div>
<h4><a href="{% pageurl page %}">{{ page.title }}</a></h4>
<a href="{% pageurl page %}" class="button button-md button-pasific hover-icon-wobble-horizontal mt25">More<i class="fa fa-shopping-basket"></i></a>
</div>
{% endfor %}
</div>
html
...
{% product_snippets calling_page=self %}
...