在Django模板(Wagtail CMS)中将变量用作标记的一部分时发生异常

时间:2019-03-23 21:59:54

标签: django django-templates wagtail

设置Django / Wagtail CMS网站。尝试为图像创建模板,该模板将大小作为变量,并包括以下模板:

{% include "patterns/molecules/media/image.html" with media=page.featured_image caption=page.image_caption imgclass="extra-wide" sizing="fill-854x480" %} 

然后在模板中,我使用以下代码:

    {% with sizing as size %}
        {% if size %}
            {% image media size as img %}
        {% else %}
            {% image media fill-1280x720 as img %}
        {% endif %}
    {% endwith %}

但是,它最终出现异常:

InvalidFilterSpecError at /slug/
Unrecognised operation: size
Request Method: GET
Request URL:    http://localhost:8000/slug/
Django Version: 2.1.7
Exception Type: InvalidFilterSpecError

0 个答案:

没有答案