1 回答
TA贡献1810条经验 获得超5个赞
您必须将三个列表放在视图中,然后将其发送到模板。然后同时在那里迭代它,如下所示...zip
def home(request):
...Your Logic...
context = { "all_teams": zip(first_team_names, second_team_names, hours_games)}
return render(request, 'profilecontent/home.html', context)
现在,解压缩模板并同时对其进行迭代...
{%extends 'profilecontent/base.html' %}
{%block content%}
<div class="container-home">
<div class="home-wrapper home-wrapper-first">
<p class='home-matches'>Przyszłe mecze <span class='home-week'>W3 D2</span></p>
<div class="match-wrapper">
<table>
{% for data in all_teams %}
<tr><td>{{ data.0.first_team }}</td><td>{{ data.2.hour_game }}</td><td>{{ data.1.second_team }}</td></tr>
{%endfor%}
</table>
</div>
</div>
<div class="home-wrapper home-wrapper-second">
</div>
</div>
{%endblock%}
添加回答
举报