Hi i am new to Django and in the process of going through the django tutorial at https://www.djangoproject.com/
But when i click on the links on the polls home page i get the following error
-- 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/
Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: ['polls/(?P<question_id>[0-9]+)/vote/$']| Request Method: | GET |
|---|---|
| Request URL: | http://127.0.0.1:8000/polls/3/ |
| Django Version: | 1.11 |
| Exception Type: | NoReverseMatch |
| Exception Value: | Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: ['polls/(?P<question_id>[0-9]+)/vote/$'] |
| Exception Location: | C:\Users\Echalon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 497 |
| Python Executable: | C:\Users\Echalon\AppData\Local\Programs\Python\Python36-32\python.exe |
| Python Version: | 3.6.0 |
| Python Path: | ['C:\\Web Development\\mysite', 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip', 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs', 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\lib', 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32', 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages'] |
| Server time: | Thu, 4 May 2017 06:31:28 +0000 |
Error during template rendering
In template C:\Web Development\mysite\polls\templates\polls\detail.html, error at line 5
Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: ['polls/(?P<question_id>[0-9]+)/vote/$']
| 1 | <h1>{{ question.question_text }}</h1> |
|---|---|
| 2 | |
| 3 | {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} |
| 4 | |
| 5 | <form action="{% url 'polls:vote' question.id %}" method="post"> |
| 6 | |
| 7 | {% csrf_token %} |
| 8 | {% for choice in question.choice_set.all %} |
| 9 | <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" /> |
| 10 | <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br /> |
| 11 | {% endfor %} |
| 12 | <input type="submit" value="Vote" /> |
| 13 | </form> |
| 14 |
Any help would be greatly appreciated.
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+unsubscribe@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/6e5bfaca-3726-4286-b4a6-e1faf0218d55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment