Save the output of a template filter to another variable

The typical way to accomplish this feat would be to use Django's "with" templatetag like so:

{% with some_object|length as some_length %} 
    {% ifequal some_length 25 %}
    {% endifequal %}
{% endwith %}

Although as always it's worth noting that if you find yourself in need of using arbitrary Python expressions in a template, there may be an easier and more logical way to structure data and make it available to the template.

0 Comments, 0 trackbacks (Trackback URL)

0 responses to Save the output of a template filter to another variable

Leave a Comment
  1. (required)
  2. Ignore this field:
  3. Don't put anything in this field:
    Don't put anything here:
  4. Leave this empty:
    (required)
  5. Your email is not publically displayed.