Having trouble loading up my poll app

52 views
Skip to first unread message

Caleb Bryson

unread,
May 28, 2018, 9:45:41 PM5/28/18
to Django users
Hey guys, I am on part 4 of writing your first django app. And I am stuck at the part where it says this "Now, go to /polls/1/ in your browser and vote in the question. You should see a results page that gets updated each time you vote. If you submit the form without having chosen a choice, you should see the error message." . I thought I was supposed to use the url "http://localhost:8000/polls/1/" but it gave me a error saying "Template does not exist at /polls/1/". I am not really sure how to fix this to move on with the tutorial. Does anyone know how to get rid of this error?

김영찬

unread,
May 28, 2018, 10:55:07 PM5/28/18
to django...@googlegroups.com
When you receive that error message "Template does not exist", most of time you are able to find errors in URL and TEMPLATE.
Please show us your urls.py and detail.html and result.html :)  

2018-05-29 10:45 GMT+09:00 Caleb Bryson <cbrys...@gmail.com>:
Hey guys, I am on part 4 of writing your first django app. And I am stuck at the part where it says this "Now, go to /polls/1/ in your browser and vote in the question. You should see a results page that gets updated each time you vote. If you submit the form without having chosen a choice, you should see the error message." . I thought I was supposed to use the url "http://localhost:8000/polls/1/" but it gave me a error saying "Template does not exist at /polls/1/". I am not really sure how to fix this to move on with the tutorial. Does anyone know how to get rid of this error?

--
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...@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/fc0f2c87-a6c9-4276-b045-2c2caf1d3e3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Caleb Bryson

unread,
May 28, 2018, 11:35:03 PM5/28/18
to Django users
P.S.: This is my first attempt at setting up a website using django so my code may look a little ruff.

here is my urls.py
from django.urls import path

from . import views

urlpatterns = [
path('', views.index, name='index'),

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

app_name = 'polls'
urlpatterns = [
path('', views.index, name='index'),
path('<int:question_id>/', views.detail, name='detail'),
path('<int:question_id>/results/', views.results, name='results'),
path('<int:question_id>/vote/', views.vote, name='vote'),
]

here is my detail.html 
<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>

and here is my result.html
<h1>{{ question.question_text }}</h1>

<ul>
{% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li>
{% endfor %}
</ul>

<a href="{% url 'polls:detail' question.id %}">Vote again?</a>

On Monday, May 28, 2018 at 9:45:41 PM UTC-4, Caleb Bryson wrote:
Reply all
Reply to author
Forward
0 new messages