Declare custom tag filter in Django template

Lutaaya Huzaifah Idris

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)
AKS

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Django - Tag inside a Template tag

Django Template syntax/tag to filter and check if a related data exists in that model

Django template tag format

django custom template tag - import model blog error

Django Form Field Placeholder text using custom template tag

Filter 2D list with template tag in Django

How to make custom template filter case insensitive? (Django 2.1)

Django view unit test conflict with custom template tag

templatetags vs custom template tags and filter in django

Django Template how to apply filter on the result returned by simple tag

django templates with-tag custom filter

dictionary in template tag django

Custom template filter syntax in django

Django tag template for date

Phalcon Custom Tag template

"TemplateSyntaxError: Invalid filter:"; custom django template filter based on django docs broken, but template tags working

Can't pass object of model in arguments of django custom template filter

Where can I put a Django custom template tag to get it used by a customised Django admin template?

Django Custom Template Tag Issue

Django custom template tag is not being executed

Django template Tag not showing

Django custom template tag

template filter tag in django - filtering {{activate_url}}

Django Custom Template Filter - How To Mention Users And Categories

django custom template tag, pass multiple arguments

Django custom template tag sort long list of 'elif'

Django filter and count in template tag

Django template use custom filter in CSS

Pass multiple arguments from Django template for loops into Django template filter or tag