I'm working with the django rest framework and I want make a order by to my json How I can make a order_by with django rest framework from the serializers.py file I have this in serializers.py
class EstablecimientoSerializer(serializers.ModelSerializer):
class Meta:
model = Establecimiento
depth = 1
fields = ('nombre','ciudad',)
order_by = (
('nombre',)
)
I have this order_by but this does nothing with the JSON
What is the correct way to do this order by in the JSON from serializers.py?
I have in views.py
class EstablecimientoViewSet(viewsets.ModelViewSet):
queryset = Establecimiento.objects.order_by('nombre')
serializer_class = EstablecimientoSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('categoria','categoria__titulo',)
Then the order_by not work because I have this filter, How I can do to make the filter work well with order_by?