Closed ciaranha closed 8 years ago
You could use the slice notation:
{% for post in posts|slice:":4" %}
Take a look at the accepted answer of this stackoverflow question for a good explanation: Explain Python's slice notation
@Jaibles could you please close the issue if the above answer solves your problem? Just to keep the issue tracker clean. Thanks!
I'm using the portfolio template and wondering how I would go about displaying only the 3 most recent projects or posts on the index page?
It obviously currently outputs all of these with
{% for post in posts %}...{% endfor %}
I've tried adding `def index(request):
get the blog posts that are published
into
blog.py
but I'm not getting any results!