摘要:
union并集,即:合并 intersection()交集 difference()差集 qs1=Course.objects.filter(price__get=240) qs2=Course.objects.filter(price__get=260) print(p1,union(p2)) p 阅读全文
摘要:
dates()查询都有哪些日期 created_at是列名,year,是要查询的参数,order为排序方式 Course.objects.dates('created_at','year',order='DESC'') Course.objects.dates('created_at','month 阅读全文
摘要:
values_list() 元组形式显示查询结果 name,age为数据库的两个列 Student.objects.values_list('name','age') values_list() 元组形式显示查询结果,且仅显示一个列的信息,需要用到flat=True Student.objects. 阅读全文
摘要:
values() 字典形式显示查询结果 name,age为数据库的两个列 Student.objects.values('name','age') 阅读全文
摘要:
distinct()去重 Student.objects.all().distinct() 阅读全文
摘要:
only仅显示一些字段 仅显示nickname,age两列的数据 Student.objects.all().only('nickname','age') 阅读全文
摘要:
defer()排除某些字段 不显示nickname,age两列的数据 Student.objects.all().defer('nickname','age') 阅读全文
摘要:
extra别名,即给列取别名 Student.objects.all().extra(select={"name":"nickname"}) nickname为列名 name为新取的别名 访问时引用别名 阅读全文
摘要:
reverse逆转,即反向排序 print(Student.objects.all().exclude(nickname='A').reverse() 阅读全文
摘要:
exclude查询时出掉或排除某个条件的信息 print(Student.objects.all().exclude(nickname='A') 阅读全文