我使用jinja填充我的html页面,如何在python中使用set()
删除输出中的重复?
下面是我的代码:
<label class="text-primary" for="search_type" style="display:inline-block;">Selected Status : </label>
{% for project_data in project_on_status_list %}
<span>{{ project_data.get_project_stage_display }}, </span>
{% endfor %}
输出:
Selected Status : In Progress, On Hold, On Hold, Completed,
期望的输出:
Selected Status : In Progress, On Hold, Completed,
答案 0 :(得分:0)
您需要过滤器唯一
`<label class="text-primary" for="search_type" style="display:inline-block;">
Selected Status :
</label>
{% for project_data in project_on_status_list %}
<span>{{ project_data.get_project_stage_display | unique }}, </span>
{% endfor %}`