0👍
Why don’t you filter for the blog posts you want to show in your view? That way you can keep the template the same:
{% for object in blogposts %}
# ...
{% endfor %}
You define blogposts in your view, which either includes 5 or 100 posts.
👤Dick
- [Answered ]-Paginated based on the alphabet (A-Z)
- [Answered ]-Django REST – create object with PrimaryKey
0👍
Ignacio is right that you want an inclusion tag, but you should know that the include
tag does not render outside the current context – it very definitely uses the same context as the block it’s in.
Your problem is probably that you’re trying to call blogpost_set
on the object_list
– but the relationship is not with the list of objects, it’s with each individual object in the list. You’d need to iterate through object_list
and then through blogpost_set.all
on each one.
Source:stackexchange.com