[Fixed]-Complex aggregation methods as single param in query string

1👍

Definitely would be good to see your MyModelList class but anyway my example as per https://docs.djangoproject.com/en/1.10/ref/class-based-views/base/

from django.http import HttpResponse
from django.views import View

class StarsModelList(generics.ListAPIView):
    queryset = StarsModel.objects.all()
    serializer_class = StarsModelSerializer
    filter_class = StarsModelFilter

    def complex_method(request):
        # do smth to input parameters if any
        return HttpResponse('Hello, World!')

    def get(self, request, *args, **kwargs):
        if request.GET.get('agg', None) == 'complex_method':
           return self.complex_method(request)
        return HttpResponse('Hi, World!')
👤sr3z

Leave a comment