【发布时间】:2020-06-13 08:21:45
【问题描述】:
我想为特定品牌的每个 product_type_id 获取 1 个产品。 所以,我写了这个查询,它返回正确的输出,但在我的产品模型中,还有其他几个字段,如 product_name、product_info 等无法访问,为什么?它只返回 product_type_id 和价格。
plans_data = Product.objects.filter(brand__brand_id = brand_data_1.brand_id).values('product_type_id').annotate(min_brand_price=Min('product_price'))
【问题讨论】:
-
因为您正在使用将查询集转换为具有指定字段的列表的“值”
-
我正在使用值对对象进行分组,请阅读问题,如果您有解决方案,请告诉我
标签: django django-models django-views django-orm