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",{"books":books})

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

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

猜你喜欢

转载自blog.csdn.net/u014248032/article/details/84382140
今日推荐