Django template tag to truncate text

djangodjango-templates

Django has truncatewords template tag, which cuts the text at the given word count. But there is nothing like truncatechars.

What's the best way to cut the text in the template at given char-length limit?

Best Answer

This has recently been added in Django 1.4. e.g.:

{{ value|truncatechars:9 }}

See doc here