mirror of
https://github.com/lemeow125/Ivy-Backend.git
synced 2024-11-17 06:39:26 +08:00
Sort logs and history in descending order
This commit is contained in:
parent
9c8889df0e
commit
78c9a67f07
2 changed files with 2 additions and 2 deletions
|
@ -7,7 +7,7 @@ class HistoricalRecordField(serializers.ListField):
|
||||||
child = serializers.DictField()
|
child = serializers.DictField()
|
||||||
|
|
||||||
def to_representation(self, data):
|
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):
|
class ProductSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
|
@ -14,4 +14,4 @@ class LogViewSet(viewsets.ModelViewSet):
|
||||||
# permission_classes = [IsAuthenticated]
|
# permission_classes = [IsAuthenticated]
|
||||||
http_method_names = ['get']
|
http_method_names = ['get']
|
||||||
serializer_class = LogSerializer
|
serializer_class = LogSerializer
|
||||||
queryset = Product.history.all().order_by('history_date')
|
queryset = Product.history.all().order_by('-history_date')
|
||||||
|
|
Loading…
Reference in a new issue