当我为多个条目投票时,for 循环中的每个条目都会重复“添加投票”按钮。关于我应该如何修复逻辑以便添加投票按钮只出现一次的任何想法?
{{ user.get_profile.votes.all }}
{% for v in user.get_profile.votes.all %}
{% if v.entry = e.entry %}
<form action="/profile/" method="post">
{% csrf_token %}
<input type='hidden' name='entry_id' value='{{ e.id }}'>
<input type='hidden' name='project_id' value='{{ p.id }}'>
<input type='hidden' name='team_id' value='{{ t.id }}'>
<input type='submit' name="remove_vote" value='Remove Vote'>
</form>
{% elif v.entry != e.entry %}
<form action="/profile/" method="post">
{% csrf_token %}
<input type='hidden' name='entry_id' value='{{ e.id }}'>
<input type='hidden' name='project_id' value='{{ p.id }}'>
<input type='hidden' name='team_id' value='{{ t.id }}'>
<input type='submit' name="add_vote" value='Add Vote'>
</form>
{% endif %}
{% empty %}
<form action="/profile/" method="post">
{% csrf_token %}
<input type='hidden' name='entry_id' value='{{ e.id }}'>
<input type='hidden' name='project_id' value='{{ p.id }}'>
<input type='hidden' name='team_id' value='{{ t.id }}'>
<input type='submit' name="add_vote" value='Add Vote'>
</form>
{% endfor %}