# 神奇的双下划线查询 # 1 年龄大于35岁的数据 # res = models.User.objects.filter(age__gt=35) # print(res) # 2 年龄小于35岁的数据 # res = models.User.objects.filter(age__lt=35) # print(res) # 大于等于 小于等于 # res = models.User.objects.filter(age__gte=32) # print(res) # res = models.User.objects.filter(age__lte=32) # print(res) # 年龄是18 或者 32 或者40 # res = models.User.objects.filter(age__in=[18,32,40]) # print(res) # 年龄在18到40岁之间的 首尾都要 # res = models.User.objects.filter(age__range=[18,40]) # print(res) # 查询出名字里面含有s的数据 模糊查询 # res = models.User.objects.filter(name__contains='s') # print(res) # # 是否区分大小写 查询出名字里面含有p的数据 区分大小写 # res = models.User.objects.filter(name__contains='p') # print(res) # 忽略大小写 # res = models.User.objects.filter(name__icontains='p') # print(res) # res = models.User.objects.filter(name__startswith='j') # res1 = models.User.objects.filter(name__endswith='j') # # print(res,res1) # 查询出注册时间是 2020 1月 # res = models.User.objects.filter(register_time__month='1') # res = models.User.objects.filter(register_time__year='2020')