help been on that for 5 days, Joining 4 tables on 2 columns

18 views
Skip to first unread message

Omar aboul makarem

unread,
Jul 17, 2020, 1:32:19 PM7/17/20
to Django users

Hey Guys please help

I have Approval model, and i want to calculate the sum of total prices of the procedures based on the company and procedure type in each Approval
now i want to get all the prices and .aggregate(Sum('price'))['price__sum']) to get the sum of all prices of the approvals i have.
the raw sql for postgresql and if my app is called main is :
now how can i change this sql to django ORM, in the documentation i read about select_related(), and F(), but i dunno how to use it in this case

Integr@te System

unread,
Jul 17, 2020, 2:25:59 PM7/17/20
to django...@googlegroups.com
Hi Omar,

You can look at this to consider:

Hope this helpful.



--
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/038b6c05-0be2-43b2-8082-f24e08858a92o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages