Skip to content
Advertisement

Django: Use firstof of if-else block inside blocktrans

I have two variables var1 and var2. I want to do this,

JavaScript

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?

Advertisement

Answer

From django 1.9 onwards, you can use firstof to assign result to context.

JavaScript

See django-docs and issue tracker for reference.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement