我想基于远程模型的字段在远程模型(遍历2模型关系)上进行注释,只有它是假的。这可能吗?
foo = CommunityProfile.objects.annotate(answered_count=Count('threadvault__unanswered'=False))
答案 0 :(得分:2)
首先过滤查询集,然后进行注释。
profiles = CommunityProfile.objects.filter(
threadvault__unanswered=False
).annotate(
answered_count=Count('threadvault')
)