728x90
반응형
board_list.html
<form name='deleteForm' action="/board/delete/" method="POST">
{% csrf_token %}
<input type="button" class="right-btn" value="엑셀 다운로드" onclick="location.href='/board/%5Eexport/xls/$'" />
<input type="button" class="right-btn" value="선택삭제" onclick="infoDelete();" />
<table class="table">
<thead>
<tr>
<th><input type="checkbox" name="selected_all"></th>
<th>기간</th>
<th>업체명</th>
<th>직책</th>
<th>이름</th>
</tr>
</thead>
<tbody>
{% for board in boards %}
{% if board.start_date|date:'Ymd' <= time|date:'Ymd' and board.end_date|date:'Ymd' >= time|date:'Ymd' %}
<tr onclick="location.href='/board/detail/{{ board.id }}'" style="cursor: pointer;">
<td onclick="event.cancelBubble=true" style="cursor: default;">
<input type="checkbox" name="selected" value="{{board.pk}}"/>
</td>
<td>{{ board.start_date|date:'Y.m.d (D)' }} ~ {{ board.end_date|date:'Y.m.d (D)' }}</td>
<td>{{ board.company }}</td>
<td>{{ board.position }}</td>
<td>{{ board.guest_name }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</form>
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('delete/', views.delete, name='delete'),
]
views.py
def delete(request):
if request.method == 'POST':
pk_list = request.POST.getlist('selected')
Board.objects.filter(pk__in=pk_list).delete()
return redirect('/board/list/')
반응형
'Project > access-control' 카테고리의 다른 글
PythonAnywhere 배포하기 (2) - 파일 올리기 (0) | 2021.12.06 |
---|---|
PythonAnywhere 배포하기 (1) - Django 설정 (0) | 2021.12.03 |
Django 게시글 수정 (0) | 2021.12.01 |
Django 게시글 등록 (0) | 2021.11.30 |
상세 페이지 연결 (0) | 2021.11.29 |