Hi All,
I have a Transaction model with a DecimalField called "amount" and a
CharField called "action".
How do I sum all the transactions, multipling the amount by -1 when the
action is REFUND?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
Sounds like two queries to me, sum all the refunds and then subtract
them from all the non-refund amounts. does that work for ya?
On May 20, 5:17 pm, Chris Withers wrote:
> Hi All,
>
> I have a Transaction model with a DecimalField called "amount" and a
> CharField called "action".
>
> How do I
John M wrote:
Sounds like two queries to me, sum all the refunds and then subtract
them from all the non-refund amounts. does that work for ya?
Not really, that requires two queries. I know this can be done in one
query in SQL, just wondering how to express that in Django ORM speak...
Chris
You could create your own manager and have it do whatever you want -- even run
the SQL query you already want to write and still return a queryset.
http://docs.djangoproject.com/en/1.1/topics/db/managers/#id2
Shawn
--
You received this message because you are subscribed to the Google Groups
"
4 matches
Mail list logo