I have two variables var1 and var2. I want to do this,
{% blocktrans %}
value of my var is: {% firstof var1 var2 %}
{% endblocktrans%}
It gives me error that 'blocktrans' doesn't allow other block tags. Because we are not allowed to use any other tag inside blocktrans, what is the solution of this kind of problem?
From django 1.9 onwards, you can use firstof
to assign result to context.
{% firstof var1 var2 as myvar %}
{% blocktrans %}
value of my var is: {{ myvar }}
{% endblocktrans%}
See django-docs and issue tracker for reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With