Skip to content

Commit a0149b1

Browse files
committed
Add views.results and results.html
1 parent 705ce6e commit a0149b1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

polls/templates/polls/results.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<h1>{{ question.question_text }}</h1>
2+
3+
<ul>
4+
{% for choice in question.choice_set.all %}
5+
<li>{{ choice.choice_text }} - {{ choice.votes }}
6+
vote{{ choice.votes|pluralize }}</li>
7+
{% endfor %}
8+
</ul>
9+
10+
<a href="{% url 'polls:detail' question.id %}">Vote again?</a>

polls/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ def vote(request, question_id):
3131
selected_choice.save()
3232
# POST 데이터를 정상적으로 처리하였으면,
3333
# 항상 HttpResponseRedirect를 반환하여 리다이렉션 처리함
34-
return HttpResponseRedirect(reverse('polls:results', args=(p.id,)))
34+
return HttpResponseRedirect(reverse('polls:results', args=(p.id,)))
35+
36+
37+
def results(request, question_id):
38+
question = get_object_or_404(Question, pk=question_id)
39+
return render(request, 'polls:results.html', {'question': question})

0 commit comments

Comments
 (0)