In my views.py I have a function dataPrint()
, which returns page, and dictionary categories_zipped
. But when I try to use this dictionary in my skills.html file using Django syntax {% for category in categories_zipped %}
it works only for the first time, when I try to use it later, it does not work. (I'm not getting any errors, the second use, just returns nothing, as shown on the images below)
def dataPrint(request):
categories = [
'all',
'javascript',
'html',
]
categories_menu = [
'All',
'JS',
'HTML',
]
return render(request, 'skill/skills.html', {'categories_zipped': zip(categories, categories_menu})
skills.html
{% for category in categories_zipped %}
<a class="link-icon" href="/skills/{{category.0}}">
<img
class="small-icon"
src="{% static '/skillsgraph/img/' %}{{category.0}}.svg"
alt="{{category.0}}'.svg'"
/>
<span class="icon-title">{{category.1}}</span>
</a>
{% endfor %}
<select name="category" class="link-list">
{% for cat in categories_zipped %}
<option value="{{ cat.0 }}">{{ cat.1 }}</option>
{% endfor %}
</select>
It renders only for the first time and renders only the first thing. If I change order (put select before a), it works only for select, but not for a's.