2014-05-21 1 views
0

false 인 경우에만 원격 모델의 필드를 기반으로 원격 모델 (2 모델 관계를 탐색)에 주석을 추가하려고합니다. 이것이 가능한가?Django 1.6 역 필드 및 조건에 대한 주석 달기

foo = CommunityProfile.objects.annotate(answered_count=Count('threadvault__unanswered'=False)) 

답변

2

먼저 쿼리 세트를 필터링 한 다음 주석을 달아 라.

profiles = CommunityProfile.objects.filter(
    threadvault__unanswered=False 
).annotate(
    answered_count=Count('threadvault') 
) 
관련 문제