<!--static/css/app.css-->
.navbar-brand {
font-family: 'Peralta', cursive;
}
<!--templates/base.html-->
{% load static %}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}Django Boards{% endblock %}</title>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
</head>
<body>
<div class="container">
<ol class="breadcrumb my-4">
{% block breadcrumb %}
{% endblock %}
</ol>
  {% block content %}
  {% endblock %}
</div>
</body>
</html> <!--现在我们有了 bast.html 模板,我们可以很轻松地在顶部添加一个菜单块:---->
<!--templates/base.html-->
{% load static %}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}Django Boards{% endblock %}</title>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="{% url 'home' %}">Django Boards</a>
</div>
</nav>
<div class="container">
<ol class="breadcrumb my-4">
  {% block breadcrumb %}
  {% endblock %}
</ol>
{% block content %}
{% endblock %}
</div>
</body>
</html> <!--在 bast.html 模板中添加这个字体:-->
{% load static %}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}Django Boards{% endblock %}</title>
<link href="https://fonts.googleapis.com/css?family=Peralta" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/app.css' %}">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
  <a class="navbar-brand" href="{% url 'home' %}">Django Boards</a>
</div>
</nav>
<div class="container">
<ol class="breadcrumb my-4">
  {% block breadcrumb %}
  {% endblock %}
</ol>
{% block content %}
{% endblock %}
</div>
</body>
</html>
<!--templates/home.html-->
{% extends 'base.html' %}
{% block breadcrumb %}
<li class="breadcrumb-item active">Boards</li>
{% endblock %} {% block content %}
<table class="table">
<thead class="thead-inverse">
<tr>
<th>Board</th>
<th>Posts</th>
<th>Topics</th>
<th>Last Post</th>
</tr>
</thead>
<tbody>
  {% for board in boards %}
    <tr>
    <td>
      <a href="{% url 'board_topics' board.pk %}">{{ board.name }}</a>
      <small class="text-muted d-block">{{ board.description }}</small>
    </td>
    <td class="align-middle">0</td>
     <td class="align-middle">0</td>
    <td></td>
    </tr>
  {% endfor %}
</tbody>
</table>
{% endblock %}
<!--templates/topics.html-->
{% extends 'base.html' %} {% block title %}
{{ board.name }} - {{ block.super }}
{% endblock %} {% block breadcrumb %}
<li class="breadcrumb-item"><a href="{% url 'home' %}">Boards</a></li>
<li class="breadcrumb-item active">{{ board.name }}</li>
{% endblock %}
{% block content %}
<!-- just leaving it empty for now. we will add core heresoon. -->
{% endblock %}

Django入门与实践-第12章:复用模板(完结)的更多相关文章

  1. Django入门与实践-第15章:用户注销(完结)

    # myproject/settings.py LOGOUT_REDIRECT_URL = 'home' http://127.0.0.1:8000/logout/ # myproject/urls. ...

  2. Django入门与实践-第26章:个性化工具(完结)

    http://127.0.0.1:8000/boards/1/topics/62/reply/ 我觉得只添加内置的个性化(humanize)包就会很不错. 它包含一组为数据添加“人性化(human t ...

  3. Django入门与实践-第13章:表单处理(完结)

    http://127.0.0.1:8000/boards/1/ http://127.0.0.1:8000/boards/2/ http://127.0.0.1:8000/boards/3/ http ...

  4. Django入门与实践-第23章:分页实现(完结)

    http://127.0.0.1:8000/boards/1/ #从现在起,我们将在 board_topics 这个视图中来操作. python manage.py shell from django ...

  5. Django入门与实践-第14章:用户注册(完结)

    http://127.0.0.1:8000/signup/ django-admin startapp accounts INSTALLED_APPS = [ 'accounts', ] # mypr ...

  6. Django入门与实践-第11章:URL 分发(完结)

    http://127.0.0.1:8000http://127.0.0.1:8000/boards/1/http://127.0.0.1:8000/boards/2/http://127.0.0.1: ...

  7. Django入门与实践-第25章:Markdown 支持(完结)

    http://127.0.0.1:8000/boards/1/topics/102/reply/ 让我们在文本区域添加 Markdown 支持来改善用户体验. 你会看到要实现这个功能非常简单. 首先, ...

  8. Django入门与实践-第24章:我的账户视图(完结)

    http://127.0.0.1:8000/settings/account/ #好的,那么,这部分将是我们最后的一个视图.之后,我们将专心来改进现有功能. #accounts/views.py fr ...

  9. Django入门与实践-第22章:基于类的视图

    http://127.0.0.1:8000/boards/1/topics/2/posts/2/edit/ http://127.0.0.1:8000/ #boards/views.py from d ...

随机推荐

  1. mongodb基础学习12-分组group操作

    group可以实现常用的统计操作,如求最大值,最小值,求和 其中reduce是最关键的操作,是对每一条记录的具体操作 下面来看例子: 分组count求和 部分结果 下面的加了个查询条件,即查询价格大于 ...

  2. 运行Maven项目时出现invalid LOC header (bad signature)

    为Maven小白,今天这问题困扰了我好久,经过多次在网上查询,终于找到了原因.明明一个小问题却耗费很多时间,着实不应该,所以必须记录一下. 报错信息如下:   对话框: 控制台: <span s ...

  3. Python实现的常用排序方法

    1.冒泡排序,相邻位置比较大小,将比较大的(或小的)交换位置 def maopao(a):     for i in range(0,len(a)):         for j in range(0 ...

  4. golang interface接口

    package main import "fmt" type Shaper interface { Area() float32 } type Square struct { si ...

  5. 两个onCreate方法?你真的了解onCreate()么?

    Activity的onCreate方法一直是我们编写一个activity最先重载的方法.细心的小伙伴在编写代码的时候回看到这样一幕: 咦,这里怎么会有两个onCreate提供给我们重载?选择困难症患者 ...

  6. 97. Interleaving String (String; DP)

    Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = ...

  7. 122. Best Time to Buy and Sell Stock II (Array;Greedy)

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. Inside Triangle

    Inside Triangle https://hihocoder.com/contest/hiho225/problem/1 时间限制:10000ms 单点时限:1000ms 内存限制:256MB ...

  9. 【校招面试 之 剑指offer】第10-2题 青蛙跳台阶问题

    题目1:一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶.求该青蛙跳上一个n级台阶共有多少种跳法? 题目2:一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶...也可以一次跳n级台阶.求该青蛙跳上一个 ...

  10. [leetcode]173. Binary Search Tree Iterator 二叉搜索树迭代器

    Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the ro ...