Hi,
I’m using django-tables2 with django-filter
in the table, I always want the results grouped by build_type_id
in filter.py got class ResultsFilter(FilterSet) and there i add to qs distinct part:
@property
def qs(self):
parent = super().qs
return parent.distinct('build_type_id').order_by('build_type_id', '-id')
and all works fine filtering working ok, problem is with ordering
I would like to be able to sort the results from distinct select in django-table2
i go postgresql query which works
select * from (
SELECT DISTINCT
ON ("builds_results"."build_type_id") "builds_results"."id",
"builds_results"."build_type_id",
"builds_results"."created_at",
"builds_results"."status"
FROM "builds_results"
ORDER BY "builds_results"."build_type_id" ASC, "builds_results"."id" DESC
) t
order by "t"."created_at" ASC
how can i get this effect in django ?