Поле 'id' ожидало число, но получило '{{\r\n choice.id }}'.

Я учусь по документации Django, но в части 4 учебника я получаю эту ошибку:

ValueError at /polls/1/vote/ Поле 'id' ожидало число, но получило '{{\r\n choice.id }}'*.

polls/views.py

def vote(request, question_id):

question = get_object_or_404(Question, pk=question_id)
try:
    selected_choice = question.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):

    return render(request, 'polls/detail.html', {
        'question': question,
        'error_message': "You didn't select a choice",
    })
else:
    selected_choice.votes += 1
    selected_choice.save()

    return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))

polls/urls.py

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

detail.html

    <form action="{% url 'polls:vote' question.id %}" method="post">
    {% csrf_token %}
    <fieldset>
      <legend><h1>{{ question.question_text }}</h1></legend>
      {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
      {% for choice in question.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 %}
</fieldset>
<input type="submit" value="Vote">
</form>
Вернуться на верх