Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django jinja subset string

{{ model.field|truncatewords:30 }}
# Example below returns just the first 30 words of the text_summary column 
# (for each line/book in the books table)
<ul>
{% for book in books.all %}
	<li>{{ book.text_summary|truncatewords:30 }}</li>
{% endfor %}
</ul>
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #django #jinja #subset #string
ADD COMMENT
Topic
Name
3+6 =