urls.py 导入相对应的模块
from django.conf.urls import url,include
from django.contrib import admin
from son1.views import *
from son1 import views
urlpatterns = [
url(r'^admin/',include(admin.site.urls)),
url(r'^index/',index,name='index'),
url(r'^page1/',page1,name='page1'),
url(r'^page2/',page2,name='page2'),
url(r'^page3/',page3,name='page3'),
]
views.py 视图
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request,'index.html')
def page1(request):
return render(request,'page1.html')
def page2(request):
return render(request,'page2.html')
def page3(request):
index.html 建.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<div>
<ul>
<li><a href="{% url 'index' %}">导航</a></li>
<li><a href="{% url 'page1' %}">主机管理</a></li>
<li><a href="{% url 'page2' %}">资产管理</a></li>
<li><a href="{% url 'page3' %}">设置</a></li>
</ul>
</div>
{% block head %}
这是头
{% endblock %}
{% block content %}
这是内容
{% endblock %}
{% block footer %}
这是脚
{% endblock %}
</body>
</html>
page1.html 建文件
<!DOCTYPE html>
<html lang="en">
<head>
{% include 'index.html' %}
<meta charset="UTF-8">
<title></title>
</head>
<body>
{% block head %}
<h1>这是头</h1>
{% endblock %}
</body>
</html>
建文件
<!DOCTYPE html>
<html lang="en">
<head>
{% include 'index.html' %}
<meta charset="UTF-8">
<title></title>
</head>
<body>
{% block content %}
<h1>这是内容</h1>
{% endblock %}
</body>
</html>
建文件
<!DOCTYPE html>
<html lang="en">
<head>
{% include 'index.html' %}
<meta charset="UTF-8">
<title></title>
</head>
<body>
{% block footer %}
<h1>这是脚</h1>
{% endblock %}
</body>
</html>
完成,第一天所以简单存点东西!