私はDjango チュートリアル (パート 4)に参加しており、ユーザーが投票への回答を選択できるフォームを作成しようとしています。質問は適切に読み込まれますが、「投票」をクリックすると (つまり、オプションを選択してフォームを送信すると)、次のエラーが表示され続けます。
Page not found (404)
Request Method: POST
Request URL: http://localhost:8000/polls/vote/6
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^polls/ ^$ [name='index']
^polls/ ^(?P<poll_id>\d+)/$ [name='detail']
^polls/ ^(?P<poll_id>\d+)/results/$ [name='results']
^polls/ ^(?P<poll_id>\d+)/vote/$ [name='vote']
^admin/
The current URL, polls/vote/6, didn't match any of these.
以下は、フォームを持つ detail.html のコードです。
{{ poll.question }}
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="/polls/vote/{{ poll.id }} " method="post">
{% csrf_token %}
{% for choice in poll.choice_set.all %}
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
{% endfor %}
<input type="submit" value="Vote" />
</form>
問題は行にあると思われますが<form action="/polls/vote/{{ poll.id }} " method="post">
、修正方法がわかりません。