본문 바로가기

Python_WEB/Try_Django

[Django]Your First Template

반응형

CodingEntrepreneurs Django 강의 정리

templates 폴더 생성>

mkdir templates

 

hello_world.html>

<h1>Hello World</h1>

 

render>

지정된 템플릿을 지정된 컨텍스트 사전과 결합하고 해당 렌더링 된 텍스트와 함께 GroupWise/Response개체를 반환

 

views>

from django.http import HttpResponse
from django.shortcuts import render

# Model View Template (MVT)
def home_page(request):
    return HttpResponse(request, "hello_world.html")


def about_page(request):
    return HttpResponse("<h1>About Us</h1>")


def contact_page(request):
    return HttpResponse("<h1>Contact Us</h1>")

 

적용 스크린샷>

반응형

'Python_WEB > Try_Django' 카테고리의 다른 글

[Django]Add Bootstrap  (0) 2020.06.13
[Django]Loading a HTML Template  (0) 2020.06.13
[Django]path vs re_path vs url  (0) 2020.06.13
[Django]Multiple Views  (0) 2020.06.13
[Django]A First URL Mapping  (0) 2020.06.13