Groups and summarys in template

24 views
Skip to first unread message

Elias Coutinho

unread,
Nov 29, 2019, 2:35:41 PM11/29/19
to Django users
Good afternoon people!

I have the following querysets:

     accounts = Account.objects.filter (person__is_representative = False) .order_by ('due date')
     groups
= Account.objects.values ('due_date'). annotate (total_day = Sum ('sold_value')). order_by ('due_date')


Accounts Returns a List of Information Sorted by Due Date
groups returns another list sorted and grouped by due date

I would like django to place a total groups in the template below the line of accounts when it realizes that the next due date is different from the previous one, ie totaling by date.

Can someone help me?

Dvenum

unread,
Nov 30, 2019, 1:36:30 AM11/30/19
to Django Users
Not sure I understand, what you doing, but you may use F() expression to compare fields in the query:
https://docs.djangoproject.com/en/2.2/ref/models/expressions/#f-expressions

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8ea05b06-1eb1-4de3-8787-6d80570a6283%40googlegroups.com.


--

Integr@te System

unread,
Nov 30, 2019, 1:37:11 AM11/30/19
to django...@googlegroups.com
Hi,

You can sellect from SO(relate to 'sold_value') as retrieve from new SO base on current time.

Or If due date time == datetime now && 'due date' != 0: retrieve 'due date'


--

Elias Coutinho

unread,
Dec 1, 2019, 7:14:57 PM12/1/19
to django...@googlegroups.com
Well, the result I expect is a list with subtotals similar to the figure below:

image.png

Can you do it without javascript?

You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/fxaeopAyJj8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHBRYSeBvJr6cDTRtUXEqsJFb03cZw66G2jk1DqY_7P7-jYq1g%40mail.gmail.com.


--
Elias Coutinho.
Aprender sobre alguns assuntos é fundamental.
Aprender sobre Deus é indiscutivelmente o melhor conteúdo.

Integr@te System

unread,
Dec 2, 2019, 2:02:23 AM12/2/19
to django...@googlegroups.com
Hi Man,
Plz try:
desired_value = Account.object.aggregate( subtotal = sum('Value', filter = Q(Date = date.todat())))




Reply all
Reply to author
Forward
0 new messages