NoReverseMatch after switching to generic views


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

Here’s my

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/',, 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 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.