Sort logs and history in descending order

This commit is contained in:
keannu125 2023-03-07 18:26:00 +08:00
parent 9c8889df0e
commit 78c9a67f07
2 changed files with 2 additions and 2 deletions

View file

@ -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):

View file

@ -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')