2👍
I think its better to user annotation to get the total_amount value:
total_done = qs.values(
'ability__ability_name',
).annotate(
total_amount=F('effective_value') + F('overage')
total=Sum('total_amount'),
).values(
'ability__ability_name', 'total_amount'
).order_by('-total_amount')
1👍
Try something like this:
total_done = qs.extra(select = {'total_amount': 'SUM(one_column + another_column)'}, )
0👍
According to the answer to https://stackoverflow.com/a/4348728/122033 (actually in the comments): “Django of course passes the fullName as an alias, which does not work with MySQL” — and my guess is neither with SQLite, which I’ve been using. 🙁
- Django admin, filter objects for inline formset
- Django email
- Failed: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it
Source:stackexchange.com