How to apply multiple filters on a Django template variable?


Question

For me this works:

{{ game.description|safe }}

But this fails:

{{ game.description|safe|slice:"65" }}

Is there a way to apply two or more filters on a variable in Django templates?

1
29
8/28/2011 7:50:45 AM

Although it's quite past when the OP posted the question, but for other people that may need the info, this seems to work well for me:

You can rewrite

{{ game.description|safe|slice:"65" }}

as

{% with description=game.description|safe %}
{{description|slice:"65"}}
{% endwith %}
29
1/27/2014 7:48:48 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon