djangodjango-templatesdjango-template-filters

How to pass the result of a tag to a filter in Django?


How do I pass the result of a tag to a filter in Django?

e.g.

{{ {% widthratio a b c %}|add: 2 }}

Solution

  • You cannot, unless the tag knows how to modify the context (those usually have xxx as variable syntax available). If it doesn't, you can write a wrapper (as a custom tag) that will.