-1👍
✅
Since writing complex templatetags is not an easy task (well documented though) i would take {% with %} tag source and adapt it for my needs, so it looks like
{% get_content_list as content %
{% for items in content %}
<h2>{{items.title}}</h2>
{% endfor %}`
3👍
If the list is in a python variable X, then add it to the template context context['X'] = X
and then you can do
{% for items in X %}
{{ items.title }}
{% endfor %}
A template tag is designed to render output, so won’t provide an iterable list for you to use. But you don’t need that as the normal context + for loop are fine.
- [Answered ]-Making a smart class factory in Django
- [Answered ]-Limit the Choices shown from ManyToMany ForeignKey
- [Answered ]-How to give {% url '' %} to a variable?
- [Answered ]-Join in Django views
- [Answered ]-Reduce queries to the same Django model when using Model.objects.all()
Source:stackexchange.com