2👍
✅
Use the slice
filter:
{% for post in blog_posts|slice:":5" %}
<li>{{ post.title }}</li>
{% endfor %}
Source:stackexchange.com