每日作业5/28

"""
今日作业
必做题
1.整理今日内容,用自己的话术和思路整理到个人博客中
2.阅读CBV源码,截图加注释到手机一份,要求做到脱稿说出流程
3.利用模版的继承及CBV完成网站首页 登陆 注册页面搭建 实现三者相互交互

urls.py

from django.conf.urls import url
from django.contrib import admin
from app01 import views

urlpatterns = [
    url(r'^admin/', admin.site.urls),

    # 模板的继承
    url(r'^home/', views.home),
    # login
    url(r'^login/',views.login),
    # reg
    url(r'^reg/',views.reg),

]

views.py

from django.shortcuts import render,HttpResponse,redirect
from django.views import View
# Create your views here.

#
def home(request):
    return render(request, 'home.html')

# login
def login(request):
    return render(request,"login.html")

# reg
def reg(request):
    return render(request, "reg.html")

reg.html

{% extends "home.html" %}

{% block content %}
    <h1 class="text-center">注册页面</h1>
    <form action="">
        <p>username:<input type="text" class="form-control"></p>
        <p>password:<input type="password" class="form-control"></p>
        <input type="submit" class="btn btn-danger">
    </form>
{% endblock %}

login.html

{% extends "home.html" %}

{% block content %}
    <h1 class="text-center">登录页面</h1>
    <form action="">
        <p>username:<input type="text" class="form-control"></p>
        <p>password:<input type="password" class="form-control"></p>
        <input type="submit" class="btn btn-success">
    </form>
{% endblock %}

home.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>图书管理系统</title>
    <!-- Bootstrap3 核心 CSS 文件 -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <!-- Bootstrap3 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- font-awesome.min.css图标库4.7版本 -->
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

</head>
<body>
  <nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
  <div class="container-fluid">
      <div class="row">
            <div class="col-md-3">
                <div class="list-group">
                  <a href="/home/" class="list-group-item active">
                    首页
                  </a>
                  <a href="/login/" class="list-group-item">登录</a>
                  <a href="/reg/" class="list-group-item">注册</a>

                </div>
            </div>
            <div class="col-md-9">
                <div class="panel panel-primary">
                  <div class="panel-heading">
                    <h3 class="panel-title">Panel title</h3>
                  </div>
                  <div class="panel-body">
                      {% block content %}
                          <div class="jumbotron">
                              <h1>Hello, world!</h1>
                              <p>...</p>
                              <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
                            </div>
                      {% endblock %}
                  </div>
                </div>
            </div>
      </div>
  </div>
</body>
</html>


选做题
1.尝试着做一做图书管理系统(将所学的知识点全部用进去)
无名有名+反向解析+模版的继承
"""

posted @ 2020-05-28 19:58  耗油炒白菜  阅读(143)  评论(0编辑  收藏  举报