COVID-19-REPORT (위치 기록 반응형 웹)
결과물
리스트 목록 페이지
list.html
{% extends 'mainBase.html' %}
{% load static %}
{% block maincontent %}
<body class="text-center">
<div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">
<header class="masthead mb-auto">
<div class="inner">
<h3 class="masthead-brand"></h3>
<nav class="nav nav-masthead justify-content-center">
<a class="nav-link" href="{% url 'index' %}">Home</a>
<a class="nav-link active" href="{% url 'list' %}">List</a>
<a class="nav-link" href="{% url 'signout' %}">Sign out</a>
</nav>
</div>
</header>
<main role="main" class="inner cover">
<h1 class="cover-heading">모든 경로</h1>
<br>
<table class="table">
<thead>
<tr>
<th scope="col">위치</th>
<th scope="col">위도</th>
<th scope="col">경도</th>
<th scope="col">날짜</th>
</tr>
</thead>
<tbody>
{% for report in report.all %}
<tr>
<td>{{ report.input_report }}</td>
<td>{{ report.input_lat }}</td>
<td>{{ report.input_lon }}</td>
<td>{{ report.input_date }} {{ report.input_time }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</main>
<footer class="mastfoot mt-auto">
<div class="inner">
<p class="text-muted font-weight-lighter">© 2020. <a
href="https://www.instagram.com/integer_ji/">IntegerJi</a> all rights reserved.</p>
</div>
</footer>
</div>
</body>
{% endblock %}
- 29 ~ 36 : for문을 사용하여 report의 모든 객체를 각각의 이름으로 반환해 준다.
views.py/list
def list(request):
report = Report.objects.filter(input_user=request.user).order_by('-input_date')
return render(request, 'list.html', {'report':report })
- report에 현재 접속자의 Report 객체를 input_date의 역순으로 넣어준다.