我试图在基本html页面中呈现一个模板。基本html有整个站点的页眉、页脚和菜单。页面的中间部分必须来自子页面。我想我一切都好了,200行,但它不工作,我看不到子页面的内容,窗体和div。我只看到基本.html对于所有请求。我错过了什么?
project
|
---templates/base.html
---templates/childpage.html
基本.html
{% load static %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="{% static 'css/custom.css' %}">
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
子页面.html
{% extends "base.html" %}
{% block content %}
<form action="" method="">
</form>
<br><br><br>
<div class="something">
<a>some content</a>
</div>
{% endblock content %}
def home(request):
return render(request, 'base.html')
def askforchild(request):
return render(request, 'childpage.html')
网址
urlpatterns = [
url(r'^admin/', admin.site.urls),
url('', views.home, name='Site Home Page'),
url('askforchild', views.askforchild, name='child page'),
]