【发布时间】:2021-05-21 23:20:05
【问题描述】:
我正在制作一个网站,显示从您打开网站之日到六天后(当前周)这周的足球比赛,我想按日期分页。
例如<previous> <19 feb - 25 feb> <next> 然后当我按下下一个<previous> <26 feb - 4 march> <next>
在views.py中。
matches 是一个字典列表,每个字典是一个单独的游戏,包含游戏的日期和其他信息,并按日期排序
def home(request):
start = datetime.now().date()
end = today + timedelta(6)
matches = request_games(today, after_week)
return render(request, "sporty/home.html",{
"matches": matches,
"start" : start,
"end": end
})
在 home.html 中
{% for match in matches %}
//match info
{% endfor %}
【问题讨论】:
-
你有什么问题?
-
我的问题是如何按周分页,一旦我打开网站显示从那天到一周后的比赛,然后当你按下一步时,你会进入下一周的比赛,所有比赛都存储在字典