0
我想基於遠程模型的字段在遠程模型(遍歷2模型關係)上進行註釋,只有當它是假的。這可能嗎?Django 1.6在反向字段和條件下注釋
foo = CommunityProfile.objects.annotate(answered_count=Count('threadvault__unanswered'=False))
我想基於遠程模型的字段在遠程模型(遍歷2模型關係)上進行註釋,只有當它是假的。這可能嗎?Django 1.6在反向字段和條件下注釋
foo = CommunityProfile.objects.annotate(answered_count=Count('threadvault__unanswered'=False))
先過濾查詢集,然後註釋。
profiles = CommunityProfile.objects.filter(
threadvault__unanswered=False
).annotate(
answered_count=Count('threadvault')
)