Home

Published

- 1 min read

django api sort fields

img of django api sort fields

The solution for this is noted below

django api sort fields

Solution

   # Sorting is done on the queryset in your views
class exampleViewSet(viewsets.ModelViewSet):
    serializer_class = exampleSerializer
    queryset = example.objects.all().order_by("columnA", "-columnB")

Try other methods by searching on the site. That is if this doesn’t work