From 4e0341a2ce7a1f07c152effdc881112ed358ee7f Mon Sep 17 00:00:00 2001 From: Simon Legtenborg Date: Mon, 13 May 2024 16:49:32 +0200 Subject: [PATCH] fix: django order exception with value ordering --- src/django_rest_aggregation/mixins.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/django_rest_aggregation/mixins.py b/src/django_rest_aggregation/mixins.py index 0962c21..0081635 100644 --- a/src/django_rest_aggregation/mixins.py +++ b/src/django_rest_aggregation/mixins.py @@ -1,3 +1,4 @@ +from django_filters.rest_framework import DjangoFilterBackend from rest_framework.decorators import action from rest_framework.response import Response @@ -9,7 +10,10 @@ class AggregationMixin: @action(methods=["get"], detail=False, url_path="aggregation", url_name="aggregation") def aggregation(self, request): - queryset = self.filter_queryset(self.get_queryset()).order_by() + queryset = self.get_queryset() + + if DjangoFilterBackend in self.filter_backends: + queryset = DjangoFilterBackend().filter_queryset(request, queryset, self) aggregator = Aggregator(request, queryset, self.get_aggregation_name()) filtered_queryset = self.filter_aggregated_queryset(aggregator.get_aggregated_queryset())