Hi Ivan,

It is very likely that your problem is caused by one of these:

- `question` is not assigned to the template context
- `question` is assigned to the template context, but it has a wrong
   value (e.g. `None`)
- the question has no `id` (it is not saved to the database yet).


This then results in this line:

`{% url 'polls:vote' question.id %}`

being something like

{% url 'polls:vote' "" %}

which does not match your URL pattern, because the pattern wants an
integer for the id.

I hope this helps!

René


On 04.05.2017 08:32, Ivan Cox wrote:
> Hi i am new to Django and in the process of going through the django
> tutorial at https://www.djangoproject.com/ 
> I have however run into problems on Part 4. I have added the following
> code to the detail.html page 
> 
> |
> <h1>{{ question.question_text }}</h1>
> 
> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
> 
> <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><br />
> {% endfor %}
> <input type="submit" value="Vote" />
> </form>
> 
> |
> 
> But when i click on the links on the polls home page i get the following
> error
> 
> 
>   NoReverseMatch at /polls/3/


-- 
René Fleschenberg

Am Stadtgarten 28, 45276 Essen, Germany
Phone: +49 1577 170 7363
E-Mail: r...@fleschenberg.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/70d0da5f-afd3-1d4c-5426-f93d8d6851cd%40fleschenberg.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to