장고의 작동구조는 MTV 구조로 동작한다.
templates폴더의 html파일은 정적인 폴더가 아니다.
static 폴더를 만들고 css, js와 같은 정적파일을 넣는다.
.html 파일에
<!DOCTYPE html> 바로 아래 {% load static %} 추가한다. (static 파일을 사용하겠다고 선언)
<head> 태그안에
<link rel="stylesheet" href="{% static 'index/bootstrap/bootstrap.min.css' %}" media="screen">
static css파일 경로 링크를 써서 적용시킨다.
notice/notice_list.html
<div class="container my-3">
<h1>Notice</h1>
<!--notie table-->
<table class="table" id="datatablesSimple">
<thead>
<tr class="thead-dark">
<th>번호</th>
<th>제목</th>
<th>작성자명</th>
<th>작성일시</th>
</tr>
</thead>
<tbody>
{% if notice_list %}
{% for n in notice_list %}
<tr>
<td>{{ n.pk }}</td>
<td><a href="{{n.get_absolute_url}}">{{ n.subject }}</a></td>
<td>작성자명</td>
<td>{{ n.create_date }}</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
notice 리스트 목록이 불러올 수 있다.
notice/notice_detail.html
<div class="container my-3">
<h1 class="border-bottom pb-3">Notice</h1>
<div class="row">
<div class="col">
<!-- Subject -->
<h2 class="mt-4">{{ notice.subject}}</h2>
<!-- Author -->
<p class="lead">
by
<a href="#">작성자명 쓸 위치</a> | {{ notice.create_date }}
</p>
<hr>
<!--Content-->
<p>{{ notice.content }}</p>
</div>
</div>
<h6 class="border-top pt-1">이전글:</h6>
<h6 class="border-bottom py-1">다음글:</h6>
</div>
추가해서 게시판 상세글 보기를 만든다.
댓글