2012-07-13 4 views

답변

1

쿼리가 사전을 반환합니다. 이 방법으로 값을 얻을 수 있습니다 :

cont_rating_tmp = EmployerReviewContractor.objects.filter(
         reviewed__id = cont.id 
          ).aggregate(average=Avg('avg_rate')) 

cont.rate=cont_rating_tmp["average"] 

내가 django aggregation doc에서 saple 복사 :

>>> from django.db.models import Max 
>>> Book.objects.all().aggregate(Max('price')) 
{'price__max': Decimal('81.20')}  <--- the result (a dictionary) 
+0

당신이 대답을 수용하는 방법을 배워야한다이 시간에. – danihp

관련 문제