django 模糊查询

django 模糊查询from django shortcuts import render from models import Book Create your views here def index req books Book objects filter name contains python return render req index html

from django.shortcuts import render
from .models import Book
# Create your views here.
def index(req):
books = Book.objects.filter(name__contains="python")
return render(req,"index.html",{"books":books})

name__后面有很多模糊查询的方法

同理,price字段支持大于等于 小于等模糊查询,日期支持查询某月的某年的等查询方法。

编程小号
上一篇 2025-03-20 13:57
下一篇 2025-02-21 12:27

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/123536.html