Wigtail feed_image未在索引页面上显示

时间:2017-03-03 08:46:34

标签: django django-models django-templates wagtail wagtail-snippet

我似乎无法弄清楚为什么我的feed_image在调用SELECT count(*) FROM data WHERE connect_timestamp < '2017-01-01 12:13:00' 时在页面上工作,但在尝试添加到索引页面时,它不会显示 - 只显示一个损坏的图像。

{{ 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'],
    }

HTML

<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>

1 个答案:

答案 0 :(得分:1)

使用以下方法查询页面树时:

pages = calling_page.get_children().live()

您最初只会获得由核心字段组成的基本Page对象,例如title和slug。这是出于性能原因 - 获取详细页面内容需要对数据库进行额外的命中。要检索包含feed_image的整页数据,请添加specific()

pages = calling_page.get_children().live().specific()