gpt4 book ai didi

python - 过滤器无效 : 'revision'

转载 作者:行者123 更新时间:2023-12-01 04:45:35 26 4
gpt4 key购买 nike

当使用以下代码时:

 {% with ""|add:revision.width|add:"x"|revision.height as dimensions %}


{% thumbnail revision.image dimensions as thumb %}
{% endwith %}

我收到以下错误:

Django Version: 1.6.11
Exception Type: TemplateSyntaxError
Exception Value:
Invalid filter: 'revision'
Exception Location: /usr/local/lib/python2.7/site-packages/django/template/base.py in find_filter, line 366
Python Executable: /usr/local/bin/python
Python Version: 2.7.9
为什么?我能做些什么来解决这个问题?

最佳答案

问题出在链中最后应用的过滤器 (revision.height)。

替换:

{% with ""|add:revision.width|add:"x"|revision.height as dimensions %}

与:

{% with ""|add:revision.width|add:"x"|add:revision.height as dimensions %}
<小时/>

您还可以将变量分配给revision.widthrevision.height:

{% with width=revision.width height=revision.height %}
{% with ""|add:width|add:"x"|add:height as dimensions %}
...
{% endwith %}
{% endwith %}

关于python - 过滤器无效 : 'revision' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29474954/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com