【发布时间】:2019-03-03 21:26:04
【问题描述】:
当我在多个字段上使用 django Prefetch 对象 (https://docs.djangoproject.com/en/2.2/ref/models/querysets/#prefetch-objects) 时:
model_a.objects.prefetch_related(Prefetch(model_b__model_c), to_attr='data')
其中 model_a 与 model_b 具有 m2m 关系,而 model_c 具有 model_b 的外键。 我似乎没有在返回的 QuerySet 的元素上获得“数据”字段。
我是不是找错地方了?
【问题讨论】: