Hi,
I need to do some annotations that require a nested sumation,
I have Bills that have Lines that in turn have Sublines: Bill -> Line -> SubLine
In order to calculate the total bill price I need to add all sublines
of every line, and then all lines of a bill.

queryset.annotate(
    total=Sum(F('lines__total') + Sum(F('lines__sublines__total')))
)

But I get an AttributeError: 'CombinedExpression' object has no attribute 'name'

Is there any other way to perform this calculation (adding two levels
of nested totals)?.


thanks!
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BDCN_uvafGH8DwJsV-_m50-yOf9teZMKwgAECOLSOz2jf511g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to