Lutaaya Huzaifah Idris
Lutaaya Huzaifah Idris

Reputation: 4020

Declare custom tag filter in Django template

Am trying to declare a custom function with 2 parameters but it isn't working as expected , am getting this error :

Invalid block tag on line 4: 'original|get_customer_by_status:'CONFIRMATION_PENDING'', expected 'endblock'. Did you forget to register or load this tag?

This is my template code :

{% original|get_customer_by_status:'CONFIRMATION_PENDING' as customer_pending_loan %}

Then my custom tag filter :

@register.filter
def get_customer_by_status(queryset, status):
    print(queryset)
    print(status)

Upvotes: 0

Views: 35

Answers (1)

AKS
AKS

Reputation: 19871

You can use with template tag:

{% with customer_pending_loan=original|get_customer_by_status:'CONFIRMATION_PENDING' %}
    your code here where you need to use customer_pending_load variable
{% endwith %}

Upvotes: 1

Related Questions