0
내 루트 폴더에 템플릿 폴더가 있고 그 안에 base.html 파일이 있습니다. 일부 html로 된 응용 프로그램이 있는데 base.html을 확장하고 싶습니다.프로젝트 루트에서 템플릿 확장 Django
<header><h3>Header here</h3></header>
{% block content %}
{% endblock %}
<footer><h3>Footer here</h3></footer>
응용 프로그램 내부의 코드는 다음과 같습니다 :
내가에서 잘못된 템플릿 이름을 얻고 어떤 이유로{% extends base.html %}
{% block content %}
<h1>{{ question.question_text }}</h1>
<ul>
{% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li>
{% endfor %}
</ul>
<a href="{% url 'polls:detail' question.id %}">Vote again?</a>
{% endblock %}
가 '확장'태그 오류 및 여기에
는 base.html 내부의 코드입니다 나는 이유를 모른다.나는이 작동하지 않습니다 아직 온라인 검색에서이 내 settings.py 파일을 업데이트 만했습니다
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_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',
],
},
},
]
따옴표를 포함하도록 템플릿을 업데이트했지만 이제는 TemplateDoesNotExist 오류가 발생합니다. 위에 표시된 디렉토리를 DIRS에 포함 시켰습니다. base.html이 예상 디렉토리에 있는지 확인했습니다. 어떤 아이디어? – dobolicious
@ dobolicious 최신 답변을 확인 – Robert
여전히 같은 오류 @ 로버트 – dobolicious