在此先感謝。Django/template_block不運行
下面我有 「的index.html」
<!DOCTYPE html>
<html>
<head>
</head>
<body>
\t {% block content %}{% endblock %}
</body>
</html>
一個代碼,我有另一個HTML代碼( 「maintab.html」)爲 「index.html的」
孩子{% extends "encyclopeida/index.html" %}
{% block content %}
<p>Hello world</p>
{% endblock %}
,但它不工作.. 我接觸路徑是 「瀏覽器 - >」 http://localhost/encyclopedia/ 「(使用URL) - >功能高清(」 由view.py 「) - > index.html的」
和下面是我的文件夾結構。
終於這是我setting.py和view.py
# Application definition
INSTALLED_APPS = [
'encyclopedia.apps.EncyclopediaConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'projectstarbucks.urls'
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',
],
},
},
]
WSGI_APPLICATION = 'projectstarbucks.wsgi.application'
from django.shortcuts import render
from .models import Content, Service
# Create your views here.
def index(request):
source_list = Content.objects.order_by('id')
menu_list = Service.objects.order_by('id')
context = {'source_list':source_list,'menu_list':menu_list}
return render(request, 'encyclopedia/index.html', context)
包括settings.py tepmlate部分,並添加'views.py' –
什麼是你想實現?對於'
你好世界
'出現? –@JahongirRahmonov是的。我想調用index.html,然後粘貼maintab.html –