NoReverseMatch after switching to generic views

Hello,

I am following this tutorial

After switching to generic views, I receive NoReverseMatch

The error message: Reverse for ‘vote’ with arguments ‘(1,)’ not found. 1 pattern(s) tried: [‘polls/<int:question_id/vote/$’]

And the error line is 5.

<h1>{{ question.question_text }}</h1>
2	
3	{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
4	
5	<form action="{% url 'polls:vote' question.id %}" method=post>
6	{% csrf_token %}
7	{% for choice in question.choice_set.all %}
8	    <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
9	    <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
10	{% endfor %}
11	<input type="submit" value="Vote">
12	</form>

Here’s my urls.py:

from django.urls import path

from . import views

app_name = 'polls'

urlpatterns = [

    path('', views.IndexView.as_view(), name='index'),

    path('<int:pk>', views.DetailView.as_view(), name='detail'),

    path('<int:pk>/results/', views.ResultsView.as_view(), name='results'),

    path('<int:question_id/vote/', views.vote, name='vote'),

]

Because I’m following the official tutorial, I should not receive any error. Please assist.

You’re missing the > after question_id in the path for this item in your urls.py file.

Thanks a lot. I’m very embarrassed now.

No need to be - it’s just one of those things you’ll get used to looking for.