django的查询
books = Book.objects.filter(id=2)
books = Book.objects.exclude(name="python").values("name","price")#排除条件
books = Book.objects.all()
books = Book.objects.all()[::2]
books = Book.objects.all()[::-1]
#first last get取到的都是实例对象,并非一个QuerySet集合对象
books = Book.objects.first()
books = Book.objects.last()
books = Book.objects.get(id=2)#只能取一条记录时才不报错
ret1 = Book.objects.first(name="python").values("name")#筛选
ret2 = Book.objects.first(name="python").values_list("name","price")## 可以获取number、price的元组列表,而不是字典
books = Book.objects.all().values("name").distinct()#去重
books = Book.objects.all().values("name").distinct().count()#字段name去重后的行数