Asma Gheisari
Asma Gheisari

Reputation: 6254

how to show first 50 words of a text field in django template

I have a field like this in my Django template:

<p>{{news.description}}<p>

I wanna show the first 50 words of this field. How can I do it?

Upvotes: 22

Views: 14156

Answers (1)

Alison R.
Alison R.

Reputation: 4294

From the documentation:

{{ news.description|truncatewords:50 }}

Upvotes: 57

Related Questions