Alvaro
Alvaro

Reputation: 12037

Django no reverse match found when passing parameters in {% url %}

I have the following url conf:

      url(r'^tournaments/(?P<tournament_id>\d+)/imports/$',
         'club.apps.main.views.imports_view',
         name='imports_tournament'),

And the following template tag:

{% url 'imports_tournament' tournament.id%}

However, this always raises no reverse url match found error.

Django version is 1.5, so the single quoted syntax should work..

What am I doing wrong?

Upvotes: 0

Views: 2655

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174614

When you pass an argument to the url tag, it assumes you are passing in a positional argument. Your url view takes a keyword argument, so you need to be explicit:

{% url 'imports_tournament' tournament_id=tournament.id %}

Upvotes: 4

Related Questions