Nips
Nips

Reputation: 13880

How to insert return value from templatetag to {% if

I have templatetag:

@register.simple_tag
def get_something(data, var1, var2):
    if data:
        if var1:
            if var2:
                return True
return False

And ho to insert this to {% if ... %} block? This is not working:

{% if get_something 1 1 0 %}

Upvotes: 1

Views: 50

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799082

You can't. Have your tag set a variable in the context, and use that variable instead.

Upvotes: 2

Related Questions