[Answered ]-Calculate Sub Table Django

1👍

You can achieve this with a combination usage of F and Sum in Django.

The detail__ allows you to access foreign key Detail

from django.db.models import F, Sum

datas = Transaction.objects.annotate(sum=Sum(F('detail__qty')* F('detail__price')))
👤Lewis

Leave a comment