이전에 공부하던 부분부터 이어서 플레이할 수 있습니다.
이어서 보기 처음부터 보기

# C:\Code\mysite\elections\views.py

# 기존 코드 유지

def results(request, area):
    candidates = Candidate.objects.filter(area = area)
    polls = Poll.objects.filter(area = area)
    poll_results = []
    for poll in polls:
        result = {}
        result['start_date'] = poll.start_date
        result['end_date'] = poll.end_date

        poll_results.append(result)

    context = {'candidates':candidates, 'area':area,
    'poll_results' : poll_results}
    return render(request, 'elections/result.html', context)
<!-- C:\Code\mysite\elections\templates\elections\result.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <title>{{area}} 여론조사 결과</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>{{area}}</h1>
<br>
<table class="table table-striped">
    <thead>
    <tr>
        <td><B>기간</B></td>
        {% for candidate in candidates %}
        <td><B>{{candidate.name}}</B></td>
        {% endfor %}
    </tr>
    </thead>
    <tbody>
    {% for result in poll_results %}
    <tr>
        <td> {{result.start_date.year}}/{{result.start_date.month}}/{{result.start_date.day}}~{{result.end_date.year}}/{{result.end_date.month}}/{{result.end_date.day}} </td>
        <td> 후보1 지지율</td>
        <td> 후보2 지지율</td>
    </tr>
    {% endfor %}
    <tbody>
</table>
</div>
</body>