-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
has_totals not working with querysets #7
Comments
a quick fix for this is: but after this another error is raised, "'list' object has no attribute 'order_by'" and this error is because my data is a list of dict not a qs, and the app it things is a queryset |
This should be fixed in master. The tricky part is that you probably are returning a ValuesQuerySet which |
so, how we can fix this? because still not working right |
After the last updates from the git, now the "has_totals" is not throw any errors, but the last field is the last field from the results,not the totals row |
That's odd, it's working for me. Can you check what data type you are actually returning in your |
I mean check it with |
Ok sorry, I answered before reading your last post.
That's the way it works. You have to take care that the total row is the last one. At the moment I don't see other simple way to achieve this. Calculating totals is not always plain, think for example if you have a column of percentage (%), you can't simply sum them. |
But why you don't create a new row and SUM all the columns? Example: in my case, each row is a different record with a different pk https://s21.postimg.org/sa0rh7ajr/Screenshot_2016_10_13_21_44_24.png |
Actually this is a very simple case you are describing, but yes, I think I may add a new attribute for the This would be a little bit arbitrary in my opinion, should it SUM any numeric value? What if the numbers are database IDs or codes of any other kind? That's up to the programmer to know |
I quess you can make something similar with the formatting attribute and the user select what columns to make sums or avg or diff |
have you have any success with this feature? |
This is not as simple as formatting as it does not apply per value and thus can not be executed at rendering time. I implemented a basic idea which works only in "list of dict" case, queryset and DataFrames are faster but will have to think about it a little bit more. Will push this on a separate branch as soon as I can and let you know, would be great if you can test it. |
i will test it first hand, now i am try to add a custom menu to the admin menus and append the report to that menu |
Pushed 'eval_totals' branch. You can define the attribute As said, at the moment it works only with list of dicts as return value of |
for 1.9 is not working, because ValuesQuerySet has been removed |
You are right, e8277bf should fix it. |
also there is a problem, when fields are methods name, auto_totals is not working, also if the columns contains 2 or more fields, is impossible to make total formating |
As highlighted in issue #6
Negative indexing is not supported
is raised when using attributehas_totals
with anaggregate
returning a queryset.The text was updated successfully, but these errors were encountered: