0

How do I call a function with arguments in template? Is there any way to do something like?

{% function(args) %}
Kumar
  • 29
  • 1
  • 4

2 Answers2

0

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".

Community
  • 1
  • 1
dan-klasson
  • 13,734
  • 14
  • 63
  • 101
-2

In your urls you have something like function.name.

You will call something like this: {% function.name parameter %}

brunozrk
  • 773
  • 1
  • 7
  • 14