最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Django使用 Bootstrap 樣式修改書籍列表過程解析

 更新時間:2019年08月09日 09:59:32   作者:Sch01aR#  
這篇文章主要介紹了Django使用 Bootstrap 樣式修改書籍列表過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

展示書籍列表:

首先修改原先的 book_list.html 的代碼:

<!DOCTYPE html>
<!-- saved from url=(0042)https://v3.bootcss.com/examples/dashboard/ -->
<html lang="zh-CN">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3個meta標簽*必須*放在最前面,任何其他內(nèi)容都*必須*跟隨其后! -->
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon"  rel="external nofollow" rel="external nofollow" rel="external nofollow" >
 
  <title>書籍列表管理</title>
  <!-- Bootstrap core CSS -->
  <link href="/static/bootstrap/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet">
  <!-- Custom styles for this template -->
  <link href="/static/dashboard.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet">
  <link rel="stylesheet" href="/static/fontawesome/css/font-awesome.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
</head>
 
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
          aria-expanded="false" aria-controls="navbar">
        <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"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >圖書管理系統(tǒng)</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Dashboard</a></li>
        <li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Settings</a></li>
        <li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Profile</a></li>
        <li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Help</a></li>
      </ul>
      <form class="navbar-form navbar-right">
        <input type="text" class="form-control" placeholder="Search...">
      </form>
    </div>
  </div>
</nav>
 
<div class="container-fluid">
  <div class="row">
    <div class="col-sm-3 col-md-2 sidebar">
      <!-- active 表示當前頁面,會加亮 -->
      <ul class="nav nav-sidebar">
        <li><a href="/publisher_list/" rel="external nofollow" >出版社列表頁</a></li>
        <li class="active"><a href="/book_list/" rel="external nofollow" >書籍列表</a></li>
        <li><a href="/author_list/" rel="external nofollow" >作者列表</a></li>
      </ul>
 
    </div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <h1 class="page-header">書籍管理頁面</h1>
 
      <div class="panel panel-primary">
        <!-- Default panel contents -->
        <div class="panel-heading">書籍列表 <i class="fa fa-thumb-tack pull-right"></i></div>
        <div class="panel-body">
          <div class="row" style="margin-bottom: 15px">
            <div class="col-md-4">
              <div class="input-group">
                <input type="text" class="form-control" placeholder="Search for...">
                <span class="input-group-btn">
                  <button class="btn btn-default" type="button">搜索</button>
                </span>
              </div><!-- /input-group -->
            </div><!-- /.col-md-4 -->
            <!-- 跳轉(zhuǎn)到另一頁面,添加新的書籍 -->
            <div class="col-md-1 pull-right">
              <a href="/add_book/" rel="external nofollow" class="btn btn-success">新增</a>
            </div>
 
          </div><!-- /.row -->
 
          <table class="table table-bordered">
            <thead>
            <tr>
              <th>#</th>
              <th>id</th>
              <th>書名</th>
              <th>出版社名稱</th>
              <th>操作</th>
            </tr>
            </thead>
            <!-- 從原先的 book_list.html 拷貝過來的代碼-->
            <tbody>
            {% for book in book_list %}
              <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ book.id }}</td>
                <td>{{ book.title }}</td>
                <td>{{ book.publisher.name }}</td>
                <td>
                  <a class="btn btn-danger" href="/del_book/?id={{ book.id }}" rel="external nofollow" >刪除</a>
                  <a class="btn btn-info" href="/edit_book/?id={{ book.id }}" rel="external nofollow" >編輯</a>
                </td>
              </tr>
            {% endfor %}
            </tbody>
          </table>
 
          <nav aria-label="Page navigation" class="text-right">
            <ul class="pagination">
              <li>
                <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" aria-label="Previous">
                  <span aria-hidden="true">«</span>
                </a>
              </li>
              <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >1</a></li>
              <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >2</a></li>
              <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >3</a></li>
              <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >4</a></li>
              <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >5</a></li>
              <li>
                <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" aria-label="Next">
                  <span aria-hidden="true">»</span>
                </a>
              </li>
            </ul>
          </nav>
        </div>
 
      </div>
    </div>
  </div>
</div>
 
 
<div class="modal fade" tabindex="-1" role="dialog" id="myModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
        </button>
        <h4 class="modal-title">用戶信息</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">郵箱</label>
            <div class="col-sm-10">
              <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
            </div>
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">密碼</label>
            <div class="col-sm-10">
              <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary">保存</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
 
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/static/jquery-3.3.1.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
 
</body>
</html>

修改過程:

運行效果:

添加書籍:

再來修改 add_book.html

<!DOCTYPE html>
<!-- saved from url=(0042)https://v3.bootcss.com/examples/dashboard/ -->
<html lang="zh-CN">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3個meta標簽*必須*放在最前面,任何其他內(nèi)容都*必須*跟隨其后! -->
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon"  rel="external nofollow" rel="external nofollow" rel="external nofollow" >
 
  <title>添加書籍</title>
  <!-- Bootstrap core CSS -->
  <link href="/static/bootstrap/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet">
  <!-- Custom styles for this template -->
  <link href="/static/dashboard.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet">
  <link rel="stylesheet" href="/static/fontawesome/css/font-awesome.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
</head>
<!-- 以上 head 部分從 book_list.html 賦值過來并加以修改 -->
 
<!-- 以下 body 部分可從 Bootstrap 網(wǎng)站上找相關(guān)代碼 -->
<body>
 
<div class="container">
  <div class="row">
    <div class="col-md-6 col-md-offset-3">
 
      <div class="panel panel-primary">
        <div class="panel-heading">添加書籍</div>
        <div class="panel-body">
          <form class="form-horizontal" action="/add_book/" method="post">
            <div class="form-group">
              <label for="book_title" class="col-sm-2 control-label">書名</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="book_title" name="book_title"
                    placeholder="書名">
              </div>
            </div>
            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">出版社</label>
              <div class="col-sm-10">
                <select class="form-control" name="publisher">
                  {% for publisher in publisher_list %}
                    <option value="{{ publisher.id }}">{{ publisher.name }}</option>
                  {% endfor %}
                </select>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-success">提交</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>

修改過程:

先寫一個 container

找一個面板,在 Bootstrap 的組件中可找到

復制代碼,并進行修改

現(xiàn)在需要一個 form 表單,在 Bootstrap 的全局 CSS 樣式中找

復制下面的代碼,替換面板代碼中的 Panel content,并進行修改

先修改 email 處

<div class="form-group">
  <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
  <div class="col-sm-10">
    <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
  </div>
</div>

修改為:

<div class="form-group">
  <label for="book_title" class="col-sm-2 control-label">書名</label>
  <div class="col-sm-10">
    <input type="text" class="form-control" id="book_title" name="book_title" placeholder="書名">
  </div>
</div>

再來修改 password 處,這里需要用到下拉列表,還是去 Bootstrap 上找

在 “菜單” -> "被支持的控件" 處

復制代碼,并進行修改

<div class="form-group">
  <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
  <div class="col-sm-10">
    <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
  </div>
</div>

修改為:

<div class="form-group">
  <label for="inputPassword3" class="col-sm-2 control-label">出版社</label>
  <!-- 下拉列表 -->
  <div class="col-sm-10">
    <select class="form-control" name="publisher">
      {% for publisher in publisher_list %}
        <option value="{{ publisher.id }}">{{ publisher.name }}</option>
      {% endfor %}
    </select>
  </div>
</div>

接著修改剩下的部分

最后在 form 表單處添加 action 和 method

運行效果:

編輯書籍:

最后修改 edit_book.html

<!DOCTYPE html>
<!-- saved from url=(0042)https://v3.bootcss.com/examples/dashboard/ -->
<html lang="zh-CN">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3個meta標簽*必須*放在最前面,任何其他內(nèi)容都*必須*跟隨其后! -->
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon"  rel="external nofollow" rel="external nofollow" rel="external nofollow" >
 
  <title>編輯書籍</title>
  <!-- Bootstrap core CSS -->
  <link href="/static/bootstrap/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet">
  <!-- Custom styles for this template -->
  <link href="/static/dashboard.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet">
  <link rel="stylesheet" href="/static/fontawesome/css/font-awesome.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
</head>
<body>
 
<div class="container">
  <div class="row">
    <div class="col-md-6 col-md-offset-3">
 
      <div class="panel panel-primary">
        <div class="panel-heading">編輯書籍</div>
        <div class="panel-body">
          <form class="form-horizontal" action="/edit_book/" method="post">
            <input type="text" style="display: none" name="id" value="{{ book_obj.id }}">
            <div class="form-group">
              <label for="book_title" class="col-sm-2 control-label">書名</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="book_title" name="book_title"
                    placeholder="書名" value="{{ book_obj.title }}">
              </div>
            </div>
            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">出版社</label>
              <div class="col-sm-10">
                <select class="form-control" name="publisher">
                  {% for publisher in publisher_list %}
                    {# 通過 if 條件判斷來選擇默認出版社 #}
                    {% if book_obj.publisher_id == publisher.id %}
                      {# 默認選擇當前書籍關(guān)聯(lián)的出版社 #}
                      <option selected value="{{ publisher.id }}">{{ publisher.name }}</option>
                    {% else %}
                      {# 其他的出版社不選中 #}
                      <option value="{{ publisher.id }}">{{ publisher.name }}</option>
                    {% endif %}
                  {% endfor %}
                </select>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-success">提交</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div> 
</body>
</html>

修改過程:

首先把 add_book.html 復制過去,然后修改相關(guān)標題,把 “添加書籍” 改為 “編輯書籍”

然后在 form 表單下一行添加一個有書籍 id 的 input 標簽

然后在書名的那個 input 處添加一個 value

然后將下拉列表的出版社選擇改為原 edit_book.html 的

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • python實現(xiàn)復制整個目錄的方法

    python實現(xiàn)復制整個目錄的方法

    這篇文章主要介紹了python實現(xiàn)復制整個目錄的方法,涉及Python中shutil模塊的相關(guān)操作技巧,需要的朋友可以參考下
    2015-05-05
  • Python中XlsxWriter模塊簡介與用法分析

    Python中XlsxWriter模塊簡介與用法分析

    這篇文章主要介紹了Python中XlsxWriter模塊用法,簡單描述了XlsxWriter模塊的功能并結(jié)合實例形式分析了Python使用XlsxWriter模塊操作xls文件的數(shù)據(jù)插入、直方圖等相關(guān)操作技巧,需要的朋友可以參考下
    2018-04-04
  • python獲取文件后綴名及批量更新目錄下文件后綴名的方法

    python獲取文件后綴名及批量更新目錄下文件后綴名的方法

    這篇文章主要介紹了python獲取文件后綴名及批量更新目錄下文件后綴名的方法,實例展示了Python針對文件后綴名的遍歷查找及修改等常用操作技巧,并對其中的關(guān)鍵知識點進行了分析與總結(jié),需要的朋友可以參考下
    2014-11-11
  • wxPython窗口的繼承機制實例分析

    wxPython窗口的繼承機制實例分析

    這篇文章主要介紹了wxPython窗口的繼承機制,較為詳細的講述了wxPython窗口的繼承機制及相關(guān)用法,并對其中的易錯點進行了簡單的分析,需要的朋友可以參考下
    2014-09-09
  • Python的10道簡單測試題(含答案)

    Python的10道簡單測試題(含答案)

    這篇文章主要介紹了Python的10道簡單測試題(含答案),學習了一段時間python的小伙伴來做幾道測試題檢驗一下自己的學習成果吧
    2023-04-04
  • python GUI庫圖形界面開發(fā)之PyQt5動態(tài)加載QSS樣式文件

    python GUI庫圖形界面開發(fā)之PyQt5動態(tài)加載QSS樣式文件

    這篇文章主要介紹了python GUI庫圖形界面開發(fā)之PyQt5動態(tài)加載QSS樣式表,需要的朋友可以參考下
    2020-02-02
  • Python中用戶輸入與while循環(huán)詳情

    Python中用戶輸入與while循環(huán)詳情

    這篇文章主要介紹了Python中用戶輸入與while循環(huán)詳情,,包括如何接收用戶輸入并進行處理,在程序滿足一定的條件時讓程序一直運行,通過獲取用戶輸入并學會控制程序在用戶想要結(jié)束時退出循環(huán),即可編寫出交互式程序,下文詳細內(nèi)容介紹,需要的朋友可以參考一下
    2022-03-03
  • 淺談Python 敏感詞過濾的實現(xiàn)

    淺談Python 敏感詞過濾的實現(xiàn)

    這篇文章主要介紹了淺談Python 敏感詞過濾的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-08-08
  • python?自定義裝飾器使用及原理詳解(最新推薦)

    python?自定義裝飾器使用及原理詳解(最新推薦)

    本文詳細介紹了Python裝飾器的原理和使用方法,包括簡單的裝飾器、帶參數(shù)的裝飾器、原函數(shù)的傳參、保留原函數(shù)元數(shù)據(jù)以及類裝飾器,通過這些講解,讀者可以全面了解裝飾器的強大功能和應用技巧,感興趣的朋友一起看看吧
    2025-02-02
  • Python利用ElementTree模塊處理XML的方法詳解

    Python利用ElementTree模塊處理XML的方法詳解

    ElementTree是python的XML處理模塊,它提供了一個輕量級的對象模,下面這篇文章就來給大家介紹了關(guān)于Python利用ElementTree模塊處理XML的方法,文中通過示例代碼介紹的非常詳細,對大家具有一定的參考學習價值,需要的朋友們下面來一起看看吧。
    2017-08-08

最新評論

哈尔滨市| 昭苏县| 蒙山县| 锡林郭勒盟| 申扎县| 昌黎县| 蒙阴县| 思南县| 淄博市| 莱西市| 盐山县| 杂多县| 玛多县| 巴东县| 江华| 盐边县| 陇川县| 彭泽县| 扶沟县| 海安县| 澄迈县| 含山县| 石泉县| 神池县| 海阳市| 吉林省| 忻城县| 天峻县| 车致| 芜湖市| 祁东县| 桐梓县| 图木舒克市| 潮州市| 和政县| 时尚| 华亭县| 绿春县| 甘肃省| 榆中县| 海阳市|