上一页 1 2 3 4 5 6 7 8 9 10 ··· 39 下一页
摘要: 新建 utils 文件夹,并创建 page.py page.py: class ShowPage(object): def __init__(self, page_num, total_count, url_prefix, per_page=10, max_page=11): ''' :param 阅读全文
posted @ 2019-08-10 22:23 Sch01aR# 阅读(585) 评论(0) 推荐(0) 编辑
摘要: 添加首页和尾页: views.py: from django.shortcuts import render from app01 import models def book_list(request): # 从 URL 中取参数 page_num = request.GET.get("page" 阅读全文
posted @ 2019-08-10 20:26 Sch01aR# 阅读(1590) 评论(0) 推荐(0) 编辑
摘要: 如果页数太多的话,全部显示在页面上就会显得很冗杂 可以在页面中显示规定的页码数 例如: book_list.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>书籍列表</title> <link r 阅读全文
posted @ 2019-08-09 22:12 Sch01aR# 阅读(909) 评论(0) 推荐(0) 编辑
摘要: models.py: from django.db import models class Book(models.Model): title = models.CharField(max_length=32) def __str__(self): return self.title class M 阅读全文
posted @ 2019-08-09 17:23 Sch01aR# 阅读(361) 评论(0) 推荐(0) 编辑
摘要: models.py: from django.db import models class Employee2(models.Model): name = models.CharField(max_length=16) age = models.IntegerField() salary = mod 阅读全文
posted @ 2019-08-09 00:27 Sch01aR# 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 单表查询: models.py: from django.db import models class Employee(models.Model): name = models.CharField(max_length=16) age = models.IntegerField() salary 阅读全文
posted @ 2019-08-08 23:56 Sch01aR# 阅读(484) 评论(0) 推荐(0) 编辑
摘要: 多对多的三种方式: ORM 自动创建第三张表 自己创建第三张表, 利用外键分别关联作者和书,关联查询比较麻烦,因为没办法使用 ORM 提供的便利方法 自己创建第三张表,使用 ORM 的 ManyToManyFiled(),使用此种方式创建多对多表的时候,没有 add() remove() 等方法 适 阅读全文
posted @ 2019-08-07 17:51 Sch01aR# 阅读(538) 评论(0) 推荐(0) 编辑
摘要: 当一张表的某一些字段查询的比较频繁,另外一些字段查询的不是特别频繁,可以把不怎么常用的字段 单独拿出来做成一张表,然后用一对一的表关联起来 这样既保证数据都完整的保存下来,又能保证检索更快 models.py: from django.db import models # 作者 class Auth 阅读全文
posted @ 2019-08-06 23:55 Sch01aR# 阅读(271) 评论(0) 推荐(0) 编辑
摘要: models.py: from django.db import models # 出版社 class Publisher(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_lengt 阅读全文
posted @ 2019-08-05 22:28 Sch01aR# 阅读(943) 评论(0) 推荐(1) 编辑
摘要: models.py: from django.db import models # 出版社 class Publisher(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_lengt 阅读全文
posted @ 2019-08-05 19:56 Sch01aR# 阅读(796) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 39 下一页