- templates μ£Όμ μ¬ν
- μΉ νλ©΄(νμ΄μ§)λ³λ‘ ν
νλ¦Ώ νμΌ(*.html)μ΄ νλμ© νμνλ―λ‘, μΉ νλ‘κ·Έλ¨ κ°λ° μ μ¬λ¬ κ°μ ν
νλ¦Ώ νμΌμ μμ±νκ² λ©λλ€.
- μ΄λ° ν
νλ¦Ώ νμΌλ€μ ν κ³³μ λͺ¨μλκΈ° μν ν
νλ¦Ώ λλ ν°λ¦¬κ° νμν©λλ€.
- ν
νλ¦Ώ λλ ν°λ¦¬λ νλ‘μ νΈ ν
νλ¦Ώ λλ ν°λ¦¬μ μ± ν
νλ¦Ώ λλ ν°λ¦¬λ‘ ꡬλΆν΄μ μ¬μ©ν©λλ€.
- members/templates/myfirst.html μμ±
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>hi</div>
</body>
</html>
- members/views.py νμΌ μμ
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
def index(request):
template = loader.get_template('myfirst.html')
return HttpResponse(template.render())
- myworld/settings.py νμΌ μμ
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'members.apps.MembersConfig'
]
- migrate
python3 manage.py migrate
- νμ΄μ¬ μΉ νλ‘κ·Έλλ° P23