Djangoがテンプレートを見つけられない理由を理解できません。 Djangoがテンプレートを見つけられない理由
project/templates/blog/intro.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
{% ifis_admin %}
<p>{{username}} is an admin!</p>
{% endif %}
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
views.py
:
from django.shortcuts import render
from django.shortcuts import render_to_response
# Create your views here.
def intro(request):
render(request, "blog/intro.html")
エラー:TemplateDoesNotExist at blog/intro.html
EDIT:また、設定をテンプレート。わからないが、それは大丈夫であるように思わ
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
'settings.py'の' TEMPLATES'では 'DIRS'は何ですか?また、プロジェクトがアプリケーション(完全なプロジェクトではない)であれば、 'APP_DIR'設定は何ですか? – grochmal
@grochmal BASE_DIR = os.path.dirname(os.path.abspath(__ file__))) –
@grochmalはテンプレートの設定で編集しました –