Reputation: 65
I use polls app on my project. URLs on Polls App
app_name = 'polls'
urlpatterns = [
path('', views.index, name='index'),
path('<int:question_id>/', views.results, name='results'),
path('<int:question_id>/results/', views.detail, name='detail'),
path('<int:question_id>/vote/', views.vote, name='vote')
]
In the detail template file, I create a form and when I click the submit button I want to go to the vote page. so I make the form element like this
<form action="{% url polls:vote question.id %}" method="post">
{$ csrf_token %}
{% 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>
{% endfor %}
<input type="submit" value="Vote">
</form>
But when I build the project, I can see the Error during template rendering error in this form. The error is:
Could not parse the remainder: ':vote' from 'polls:vote'
Please help me to check this
Upvotes: 1
Views: 60
Reputation: 7330
Change here
<form action="{% url 'polls:vote' question.id %}" method="post">
See the docs for more info
Upvotes: 2