【发布时间】:2019-04-23 22:15:39
【问题描述】:
假设汽车有多个轮子,一个轮子只有一种颜色。
第 4 行是否执行 SQL 查询?
cars = Car.objects.prefetch_related('wheel_set__color')
for car in cars:
for wheel in car.wheel_set:
print(wheel.color)
【问题讨论】:
标签: python django django-models orm django-orm