Truncates a value to n words and appends an ellipsis (…).
Variable
blurb_text = 'You are pretty smart!'
Template
{{ blurb_text|truncatewords:3 }}
Result
You are pretty…
Argument: n
(required)
– number of words to truncate to.
Truncates a value to n words and appends an ellipsis (…).
blurb_text = 'You are pretty smart!'
{{ blurb_text|truncatewords:3 }}
You are pretty…
Did we get something wrong? Is there a use case for the
truncatewords filter that we should add?
Please let us know.
Commentary
You should not use the
truncatewordsfilter on HTML pages. Usetruncatewords_htmlinstead.See also:
truncatecharstruncatechars_htmltruncatewordstruncatewords_html