[英]Declare custom tag filter in Django template
我試圖用 2 個參數聲明一個自定義函數,但它沒有按預期工作,我收到此錯誤:
Invalid block tag on line 4: 'original|get_customer_by_status:'CONFIRMATION_PENDING'', expected 'endblock'. Did you forget to register or load this tag?
這是我的模板代碼:
{% original|get_customer_by_status:'CONFIRMATION_PENDING' as customer_pending_loan %}
然后我的自定義標簽過濾器:
@register.filter
def get_customer_by_status(queryset, status):
print(queryset)
print(status)
您可以with
模板標簽with
使用:
{% with customer_pending_loan=original|get_customer_by_status:'CONFIRMATION_PENDING' %}
your code here where you need to use customer_pending_load variable
{% endwith %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.