728x90
반응형

home 생성 방법

 

1️⃣ templates 폴더에 home.html 생성해서 아래 코드 추가

{% extends "base.html" %}

{% block contents %}
<div class="row mt-5">
    <div class="col-12 text-center">
        <h1>홈페이지</h1>
    </div>
</div>
<div class="row mt-1">
    <div class="col-12">
        <button class="btn btn-primary btn-block" onclick="location.href='/board/list/'">게시물 보기</button>  
    </div>
</div>
{% endblock %}



2️⃣ views.py에 아래코드 추가

def home(request):
    
    return render(request, 'home.html')



3️⃣ urls.py에 아래 코드 추가

from board.views import home

urlpatterns = [
    ...
    path('', home),
]
반응형
복사했습니다!