morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
215 stars 65 forks source link

m2m_foreign_field aggregate values #117

Open TITANHACKY opened 1 year ago

TITANHACKY commented 1 year ago

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

elementace commented 9 months ago

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

TITANHACKY commented 6 months ago

Hi @elementace,

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

elementace commented 6 months ago

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

TITANHACKY commented 6 months ago

Nice