It is able to write {{ myval.add:5 }}
, {{ myval|add:value }}
and even {{ myval|add:-5 }}
.
However, I can't find out what I should type to add value * -1 like {{ myval|add:-value }}
. This doesn't work, sadly.
{% %} and {{ }} are part of Django templating language. They are used to pass the variables from views to template. {% %} is basically used when you have an expression and are called tags while {{ }} is used to simply access the variable.
A Django template is a text document or a Python string marked-up using the Django template language. Some constructs are recognized and interpreted by the template engine. The main ones are variables and tags. A template is rendered with a context.
You need to use double quotes:
{{ myval|add:"-5" }}
This subtracts five from myval
.
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