Limit number of characters with Django Template filter

If the “my_variable” is a string, you can take advantage of the slice filter, which treats the string as a list of characters. If it’s a set of words, the rough equivilant is truncatewords – but that doesn’t quite sound like your need.

truncatewordsalso adds an ellipsis ... at the end of the truncated result.

Usage would be something like

{{ my_variable|slice:":255" }}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)