gpt4 book ai didi

python - 反转 '',参数 '' 和关键字参数 '{}' 未找到

转载 作者:太空宇宙 更新时间:2023-11-04 10:41:50 25 4
gpt4 key购买 nike

我有网址:

url(r'^tournament/(?P<tournament_id>\d+)/tour/$', chess.views.first_tour, name = 'first_tour'),    
url(r'^tournament/(?P<tournament_id>\d+)/tour/match/(?P<pk>\d+)/$', chess.views.edit_match, name = 'edit_match'),

观点:

def first_tour(request, tournament_id):
...
matches = []
for item in items:
match = Match.objects.get(...)
matches.append(match)
return render(request, 'first_tour.html', {'matches':matches})

def edit_match(request, tournament_id, match_id ):
pass

一个模板,其中我有一个用于匹配和每个匹配的循环:

<a href="{% url 'edit_match' match.pk %}">Enter results</a>

为什么会出现错误:找不到带参数“(5L,)”和关键字参数“{}”的“edit_match”的反向。出现了吗?

最佳答案

您需要在 URL 中指定所有值:

{% url 'edit_match' tournament_id=... pk=match.pk %}

您目前只为 pk 指定了一个值,这意味着 Django 无法找到一个名为 edit_match 的 url 匹配(即,它有一个未命名的参数)。您的 edit_match 有两个命名参数。

关于python - 反转 '',参数 '' 和关键字参数 '{}' 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20146208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com