#1 价格在[100,200,300]这个范围内
Book.objects.filter(price__in=[100,200,300])
# 2 大于,小于,大于等于,小于等于
Book.objects.filter(price__gt=100)
Book.objects.filter(price__lt=100)
Book.objects.filter(price__gte=100)
Book.objects.filter(price__lte=100)
# 3 范围
Book.objects.filter(price__range=[100,200])
# 包含
Book.objects.filter(title__contains="python")
# 4 忽略大小写包含
Book.objects.filter(title__icontains="python")
# 5 以xx开头
Book.objects.filter(title__startswith="py")
# 6 时间类型,年份是2012年的
Book.objects.filter(pub_date__year=2012)
# 基于双下滑线的模糊查询
# 1 in条件
# res=models.Book.objects.filter(name__in=['西游记', '红楼梦'])
# print(res)
# 2 大于,小于,大于等于,小于等于
# res=models.Book.objects.filter(id__gt=2)
# res=models.Book.objects.filter(id__lt=2)
# res=models.Book.objects.filter(id__gte=2)
# res=models.Book.objects.filter(id__lte=2)
# print(res)
# 3 rang 范围 BETWEEN 1 AND 3
# res=models.Book.objects.filter(id__range=[1,3])
# print(res)
# 包含
# res=models.Book.objects.filter(name__contains="红")
# print(res)
# 忽略大小写的包含
# res=models.Book.objects.filter(name__icontains="红")
# print(res)
#
# res=models.Book.objects.filter(name__startswith="红")
# print(res)
# res = models.Book.objects.filter(name__endswith='梦')
# print(res)
#
# res=models.Book.objects.filter(publish_date__year='2020')
# res=models.Book.objects.filter(publish_date__month='9')
# print(res)