在Django doc中,
select_related() "跟随"外键关系,在执行查询时选择其他相关对象数据. prefetch_related() 对每个关系进行单独查找,并在Python中进行"加入".
select_related() "跟随"外键关系,在执行查询时选择其他相关对象数据.
select_related()
prefetch_related() 对每个关系进行单独查找,并在Python中进行"加入".
prefetch_related()
"在python中加入"是什么意思?有人能说明一个例子吗?
我的理解是,对于外键关系,使用select_related; 对于M2M关系,请使用prefetch_related.它是否正确?
select_related
prefetch_related
python django django-models django-orm
django ×1
django-models ×1
django-orm ×1
python ×1