I am aware that one can create template filters in Django templates such as
{{ "abcdef"|makeUppercase }}
Can one create template filters that accept two arguments in Django? Suppose I wanted to create a template filter that found the logarithm of n to base m. How do I do that?
Thank you.
That’s not a template tag, that’s a template filter. And yes, you can accept an additional argument:
The arguments to this filter are the value of foo and “bar”. Note that you can only send two arguments: if you need more, you’ll have to pass them inside the second argument separated by commas, and parse them within the template.
If you just need a standalone template tag, you can use the
@simpletagdecorator to write one that takes as many arguments as you like. These are called by the normal tag syntax: