2015-04-06 39 views
1

使用下面的代碼:無效的過濾器: '修正'

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

爲什麼?我能做些什麼來解決它?

回答

2

問題是您最近在鏈中應用的過濾器(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 %}