웹개발/Django 웹서비스 개발(인프런)
32. (app2) 투표결과 페이지 만들기 (result메소드 수정)
Storage Gonie
2019. 2. 19. 21:53
반응형
1. views.py의 results메소드 수정
- detail.html -> vote메소드 -> result메소드 -> results.html 대략 이 순서로 돌아감
def results(request, question_id):
question = get_object_or_404(Question, qk = question_id)
return render(request, 'polls/results.html', {'question': question})
2. templates/polls/results.html 생성
<h1>{{question.question_text}}</h1>
<ul>
{% for choice in question.choice_set.all %}
<li>{{choice.choice_text}} --- {{choice.votes}} 득표</li>
{% endfor %}
</ul>
<a href="{% url 'polls:detail' question.id %}">다시 투표하기</a>
반응형