ExprTag - Calculating python expression and saving the result to a variable
This tag can be used to calculate a python expression, and save it into a template variable which you can reuse later or directly output to template. So if the default django tag can not be suit for your need, you can use it. How to use it {% expr "1" as var1 %} {% expr [0, 1, 2] as var2 %} {% expr _('Menu') as var3 %} {% expr var1 + "abc" as var4 %} ... {{ var1 }} for 0.2 version {% expr 3 %} {% expr "".join(["a", "b", "c"]) %} Will directly output the result to template Syntax {% expr python_expression as variable_name %} python_expression can be valid python expression, and you can even use _() to translate a string. Expr tag also can used context variables.
- tag