django-ajax-datatable icon indicating copy to clipboard operation
django-ajax-datatable copied to clipboard

m2m_foreign_field aggregate values

Open TITANHACKY opened this issue 1 year ago • 4 comments

Currently there is no aggreate values for m2m_foreign_field like count, sum. If there is aggregate values then there is no need to write initial query set

TITANHACKY avatar Jul 18 '23 05:07 TITANHACKY

@TITANHACKY How did you go about solving this problem? More importantly, I was hoping to be able to sort by a sum of values

elementace avatar Feb 11 '24 06:02 elementace

Hi @elementace,

I had modified get_initial_queryset and queried the data using annotate method and calculated the sum, count

TITANHACKY avatar May 02 '24 08:05 TITANHACKY

Thanks @TITANHACKY , for completion sake; I did it in the filter queryset method, to save in some extra compute.

elementace avatar May 02 '24 08:05 elementace

Nice

TITANHACKY avatar May 02 '24 12:05 TITANHACKY