Reputation: 67
I have urls:
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'),
Views:
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 template where I have a loop for matches and for each:
<a href="{% url 'edit_match' match.pk %}">Enter results</a>
Why does an error: Reverse for 'edit_match' with arguments '(5L,)' and keyword arguments '{}' not found. appear?
Upvotes: 1
Views: 9709
Reputation: 122516
You need to specify all values in the URL:
{% url 'edit_match' tournament_id=... pk=match.pk %}
You're currently only specifying a value for pk
which means Django can't find an url called edit_match
that matches (i.e., that has one unnamed parameter). Your edit_match
has two named parameters.
Upvotes: 4