728x90
반응형

리스트에서 행 클릭시 상세 페이지 연결하기

 

board_list.html 👇

<div class="intro">
    <h3 class="animate-this">{{ time|date:'Y년 m월 d일' }}</h3>
        <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>
    

    <div class="row">
        <div class="col-12">
            <button onclick="location.href='/board/write/'">등록</button>
        </div>
    </div>
</div>

 


board_detail.html 👇

{% extends "base.html" %}

{% block contents %}
<section id="contact">
    <div class="row contact-content">
        <div class="col-seven tab-full animate-this input-box">
        <h5>Enter the number of people entering</h5>
        <form method="POST" action="{% url 'update' pk=board.id %}" enctype="multipart/form-data">
            {% csrf_token %}
            <div class="form-field">
                <label for="start_date">시작일</label>
                <input type="date" class="form-control" name="start_date" value="{{ board.start_date|date:'Y-m-d' }}" />
                <label for="end_date">종료일</label>
                <input type="date" class="form-control" name="end_date" value="{{ board.end_date|date:'Y-m-d' }}" />
                <label for="company">업체명</label>
                <input type="text" class="form-control" name="company" value="{{ board.company }}" />
                <label for="position">직책</label>
                <input type="text" class="form-control" name="position" value="{{ board.position }}" />
                <label for="guest_name">이름</label>
                <input type="text" class="form-control" name="guest_name" value="{{ board.guest_name }}" />
            </div>
            <button type="submit" class="btn btn-primary">수정</button>
            <button type="button" class="btn btn-primary" onclick="location.href='/board/list/'">돌아가기</button> 
        </form>
    </div>
</div>
</section>
{% endblock %}

 


urls.py 👇

from django.urls import path
from . import views

urlpatterns = [
    path('detail/<int:pk>/', views.board_detail, name='detail'),
    path('list/', views.board_list),
]

 

반응형

'Project > access-control' 카테고리의 다른 글

Django 게시글 수정  (0) 2021.12.01
Django 게시글 등록  (0) 2021.11.30
Xlsxwriter 한글파일명 설정 및 행 높이 조절  (0) 2021.11.26
Xlsxwriter 엑셀 export 기능 구현  (0) 2021.11.25
Django home 만들기(index page)  (0) 2021.11.24
복사했습니다!