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:
re...@fleschenberg.net