Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django 1.9.4模板继承不起作用_Python_Django - Fatal编程技术网

Python Django 1.9.4模板继承不起作用

Python Django 1.9.4模板继承不起作用,python,django,Python,Django,我是Django的新用户。在我新的1.9.4项目中,我创建了一个名为“personal”的新应用程序。这是应用程序源目录树: personal -templates --personal ---main.html ---content.html 在personal/view.py中: from django.shortcuts import render def index(request): return render(request, 'personal/main.html')

我是Django的新用户。在我新的1.9.4项目中,我创建了一个名为“personal”的新应用程序。这是应用程序源目录树:

personal
-templates
--personal
---main.html
---content.html
在personal/view.py中:

from django.shortcuts import render
def index(request):
    return render(request, 'personal/main.html')
在main.html中

<!doctype html>
  <html lang="en">
    <body>
     <p>Hi everyone!</p>
     {% block content %}
     {% endblock %}
    </body>
  </html> 
所以,当我启动服务器时,django只呈现“Hi everyone”,而不扩展内容块“My personal content”

为什么??
感谢您呈现了布局,而不是实际的模板。你的观点应该是:

from django.shortcuts import render
def index(request):
    return render(request, 'personal/content.html')
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',
            ],
        },
    },
]
from django.shortcuts import render
def index(request):
    return render(request, 'personal/content.html')