morlandi / django-ajax-datatable

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

m2m_foreign_field aggregate values #117

Open TITANHACKY opened 11 months ago

TITANHACKY commented 11 months 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 4 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 2 months ago

Hi @elementace,

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

elementace commented 2 months ago

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

TITANHACKY commented 2 months ago

Nice