How do I call a function with arguments in template? Is there any way to do something like?
{% function(args) %}
How do I call a function with arguments in template? Is there any way to do something like?
{% function(args) %}
Yes there is. It's called custom template filters
Custom filters are just Python functions that take one or two arguments:
The value of the variable (input) – not necessarily a string.
The value of the argument – this can have a default value, or be left out altogether.
For example, in the filter {{ var|foo:"bar" }}, the filter foo would be passed the variable var and the argument "bar".
In your urls you have something like function.name.
You will call something like this: {% function.name parameter %}