【发布时间】:2021-11-30 21:04:20
【问题描述】:
我有一个主页模板,其中包含指向我想要迭代呈现的许多其他页面的链接:(由于 python 语法,这显然不起作用)
{% for idx, category in enumerate(categories) %}
<div class="box">
a href={% url 'category_links[idx]' %}> {{category}}</a>
div>
{% endfor %}
我有以下网址,从我的角度来看,我也将它们传递给我的模板:
category_links = ['journals', 'proceedings', 'books', 'articles_in_books', 'talks', 'poster', 'habilitations', 'phd_thesis', 'bachelor_master_diploma_thesis', 'lectures', 'conferences', 'calls_and_awards', 'telegrams_and_circulars']
我知道{{forloop.counter0}},但无法正确集成它。
非常感谢您的帮助!
【问题讨论】:
标签: python django django-templates