缓存集
1、filter
2、exclude
3、all
4、都不会真正的去查询数据库
5、只有我们在迭代结果集,或者获取单个对象属性的时候,它才会去查询数据库
6、懒查询
- 为了优化数据库结构
查询条件
属性__运算符=值
运算符 gt(大于) lt(小于) gte(大于等于) lte(小于等于) = in contains类似于模糊查询 like startwith endswith exact
前面同时添加不i,ignore 忽略
1、创建类,继承Model
2、外键
3、多对多
4、Tb.objects.create(**{})
5、Tb.objects.filter().update()
6、delete
7、Tb.objects.filter().first()
8、 -- .all [obj,obj,]
-- .values[{},{}]
-- .values_list[(),()]
9、get
10、反向 _set
11、F和Q
12、releated_name
13、add
14、exsit
15、__跨表
16、get_or_create
17、set
18、remove
19、clean
20、 obj = User(xx)
obj.save()
21、null = True 针对数据库
22、外键:__id
23、引号
24、命令
25、自动创建第三张表
26 、聚合查询
27、blank=True 针对django admin
28、filter(id__in=[])
29、distinct
30、 count
31、__str__
32、数据库字段大小写不敏感
33、QuerySet切片取值
34、filter(id_range=[])
35、reverse
36、id__gt
37、id__contains
38、连接MY
39、.last()
40、python manage.py shell
41、order_by()
42、id__lt
43、exclude()
44、name_startswith
45、filter(-id)
46、惰性机制
47、aggregate
48、flush
49、Q(1|)
50、verbose_name
51、关联查询
主表,驱动表
52、关联删除
53、__regex
一、创建类
class UserInfo(model.Model)
age = CharField(是否为空,类型,长度,列名,索引=True||| 错误提示,自定义验证规则)
一对多
多对多
一对一