zoukankan      html  css  js  c++  java
  • django框架代码基础

    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>
    完成,第一天所以简单存点东西!
     
  • 相关阅读:
    关于Oracle
    form表单中包含特殊字符,需要转义。
    mysql5.7解压版安装步骤
    mysql报1055错误
    配置maven私有仓库
    全选,反选
    前后端数据交互(json)
    正则表达式匹配html标签里的中文
    excel创建行、插入行、设置样式
    Python 中文字符的输出
  • 原文地址:https://www.cnblogs.com/feifang/p/6243010.html
Copyright © 2011-2022 走看看