# settings.py
import os
BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATES_DIR = os.path.join(BASE_DIR, "templates")
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR, ],
# 중요! 여기에 설정해준 경로로 TEMPLATES를 찾아온다
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
# views.py
from django.shortcuts import render
def index(request):
return render(request, 'myApp/index.html', context=my_dict)
# index.html 경로 = tempaltes/myApp/index.html