6 | | In [5]: Employee.objects.annotate(Sum('owner__employee__number')).values() |
7 | | Out[5]: [{'status': u'not_active', 'number': 3, u'id': 2, 'owner__employee__number__sum': 7, 'start_date': datetime.date(2015, 2, 23), u'owner_id': 1}, {'status': u'active', 'number': 4, u'id': 1, 'owner__employee__number__sum': 7, 'start_date': datetime.date(2015, 2, 23), u'owner_id': 1}] |
| 6 | In [8]: Employee.objects.annotate(Min('owner__employee__number')).values() |
| 7 | Out[8]: [{'status': u'not_active', 'number': 3, u'id': 2, 'owner__employee__number__min': 3, 'start_date': datetime.date(2015, 2, 23), u'owner_id': 1}, {'status': u'active', 'number': 4, u'id': 1, 'owner__employee__number__min': 3, 'start_date': datetime.date(2015, 2, 23), u'owner_id': 1}] |
9 | | In [6]: Employee.objects.filter(number=4).annotate(Sum('owner__employee__number')).values() |
10 | | Out[6]: [{'status': u'active', 'number': 4, u'id': 1, 'owner__employee__number__sum': 7, 'start_date': datetime.date(2015, 2, 23), u'owner_id': 1}] |
| 9 | In [9]: Employee.objects.filter(number=4).annotate(Min('owner__employee__number')).values() |
| 10 | Out[9]: [{'status': u'active', 'number': 4, u'id': 1, 'owner__employee__number__min': 3, 'start_date': datetime.date(2015, 2, 23), u'owner_id': 1}] |