上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 39 下一页
摘要: 网站中通常会有一个导航条,如下图 这个导航条在很多页面都会存在 可以把导航条做成一个组件,让要显示导航条的网页包含 导航条组件 nav.html: <h1>假装这是一个导航条</h1> 用 muban_test.html 来导入: <hr>{# 导入导航条组件 #} {% include 'nav. 阅读全文
posted @ 2019-07-29 18:05 Sch01aR# 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 可以把多个页面相同的部分提取出来,放在一个母板里,这些页面只需要继承这个母板就好了 通常会在母板中定义页面专用的 CSS 块和 JS 块,方便子页面替换 定义块: {% block 名字 %} {% endblock %} views.py 中添加函数: from django.shortcuts 阅读全文
posted @ 2019-07-29 17:21 Sch01aR# 阅读(389) 评论(0) 推荐(0) 编辑
摘要: 标签使用 {% %} 注释语句:{# #} for 循环: views.py: from django.shortcuts import render, redirect, HttpResponse from app01 import models # Filter 测试 def filter_te 阅读全文
posted @ 2019-07-26 21:29 Sch01aR# 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 自定义过滤器的文件: 在 app01 下新建一个 templatetags 的文件夹,然后创建 myfilter.py 文件 这个 templatetags 名字是固定的,myfilter 是自己起的 myfilter.py: from django import template register 阅读全文
posted @ 2019-07-26 20:50 Sch01aR# 阅读(609) 评论(0) 推荐(0) 编辑
摘要: 通过管道符 "|" 来使用过滤器,{{ value|过滤器:参数 }} Django 的模板语言中提供了六十个左右的内置过滤器 urls.py: from django.conf.urls import url from django.contrib import admin from app01 阅读全文
posted @ 2019-07-26 19:56 Sch01aR# 阅读(1063) 评论(0) 推荐(0) 编辑
摘要: 前言: 在 Django 模板语言中变量用 {{ }},逻辑用 {% %} 在 urls.py 中添加对应关系 from django.conf.urls import url from django.contrib import admin from app01 import views urlp 阅读全文
posted @ 2019-07-25 22:57 Sch01aR# 阅读(3008) 评论(0) 推荐(0) 编辑
摘要: 在作者列表页面的操作栏中加上编辑按钮 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>作者列表</title> </head> <body> <h1>作者列表</h1> <table border="1"> 阅读全文
posted @ 2019-07-24 22:39 Sch01aR# 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 修改 author_list.html,添加删除按钮 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>作者列表</title> </head> <body> <h1>作者列表</h1> <table bord 阅读全文
posted @ 2019-07-24 20:40 Sch01aR# 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 在 book_list.html 的页面下方加上 “添加作者” 的链接 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>作者列表</title> </head> <body> <h1>作者列表</h1> <t 阅读全文
posted @ 2019-07-24 20:00 Sch01aR# 阅读(658) 评论(0) 推荐(0) 编辑
摘要: 在 views.py 中添加展示作者列表的函数 from django.shortcuts import render, redirect, HttpResponse from app01 import models # 展示出版社列表 def publisher_list(request): pa 阅读全文
posted @ 2019-07-24 17:10 Sch01aR# 阅读(517) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 39 下一页