Den 06/02/2014 kl. 12.34 skrev ST <sej...@googlemail.com>:

> This didn't work - it produced a "SELECT  FROM" query, which obviously didn't 
> work - tried adding 'amount' to the values_list, but that didn't help either. 
> Eventually got it to work by using .only('member', 'amount') instead, and it 
> *was* fast, but it didn't quite do what we need: we only want the 
> *outstanding* credit/debt, i.e. some member might have many transactions, but 
> they all add up to zero - so instead of increasing both total_debt and 
> total_credit by that value, it shouldn't affect the totals. Which is why I 
> wanted to total up by members first... any idea how to get that to work ?

Instead of spending a lot of time trying to bend the Django ORM to do what you 
want, just keep the raw SQL that you know works, and add tests to your test 
suite. The ORM is really nice, but sometimes it's just not worth the hassle.

Erik

-- 
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/FE4FC4FE-AD80-421B-A32C-7EFE299F20EC%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to