You need to specify the field of the value in your ORM statement. I don’t know what your field name is, but this assumes that it is “value”:
aggregate(Sum(‘payment__value’))
--
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...@googlegroups.com.
To post to this group, send email to
django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/c47e4bb7-626c-4b07-9ab5-55d68fe4d566%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
This is how I finally solved my problem!!!
The following is a copy of my ORM statement:
Visit.objects.filter(visit_date = mydate).aggregate(total =
Sum('visit_payment'))
{'total': Decimal('27')}
This total is the total of the foreign key ids. 9 records each
with a key of 3 = 9 x 3 = 27
The way I solved this problem is to put another variable in the loop where I was printing the records to Reportlab PDF file and I incremented this variable with the value that was being printed. What was being printed was the value from the look-up table so I was able to get a Sum from that.
Here is the code of how I did it: vi = Visit.objects.filter(visit_date = mydate); vip = 0; for v in vi:; vi_pay = str(v.visit_payment); vip += int(vi_pay)
Here is how the Reportlab is built: Also in the same loop as
above I have the lines: vi_pat = str(v.patient);
pa1.drawString(x, y, str(vi_pat)); pa1.drawString(x + 175, y,
str(vi_pay))
Each of these are on a separate line in my code.
Hopefully this will help anyone with similar problems.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a17d4eeeb804cc89c4cda5eaca8b050%40ISS1.ISS.LOCAL.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c47e4bb7-626c-4b07-9ab5-55d68fe4d566%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a17d4eeeb804cc89c4cda5eaca8b050%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/03e77e95-26b7-01e9-e11b-beca97d16176%40gmail.com.
vi is just a variable that I created in my code. It is just short for visit. It has NOTHING to do with the vi editor program. My editor is Geany.
I am using the Django ORM to query my database.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKdOBri-aqw1PzHfDywspUHnYzYT-HYNsXGbWqPHO%2BFXyuN43A%40mail.gmail.com.