diff --git a/ivy/products/serializers.py b/ivy/products/serializers.py index 33dd5b4..c7dace1 100644 --- a/ivy/products/serializers.py +++ b/ivy/products/serializers.py @@ -7,7 +7,7 @@ class HistoricalRecordField(serializers.ListField): child = serializers.DictField() def to_representation(self, data): - return super().to_representation(data.values('quantity', 'history_date').order_by('history_date')) + return super().to_representation(data.values('quantity', 'history_date').order_by('-history_date')) class ProductSerializer(serializers.HyperlinkedModelSerializer): diff --git a/ivy/products/views.py b/ivy/products/views.py index 18034ea..af0f55f 100644 --- a/ivy/products/views.py +++ b/ivy/products/views.py @@ -14,4 +14,4 @@ class LogViewSet(viewsets.ModelViewSet): # permission_classes = [IsAuthenticated] http_method_names = ['get'] serializer_class = LogSerializer - queryset = Product.history.all().order_by('history_date') + queryset = Product.history.all().order_by('-history_date')