From 06c97d75a076934bf2c8e89db6b31ecc466dde31 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 11 Mar 2020 12:41:44 +0100 Subject: [PATCH] Logs are decreasing ordered --- apps/api/urls.py | 1 + apps/logs/api/views.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/api/urls.py b/apps/api/urls.py index 9bbe1978..95ed5f99 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -27,6 +27,7 @@ class UserSerializer(serializers.ModelSerializer): 'user_permissions', ) + class ContentTypeSerializer(serializers.ModelSerializer): """ REST API Serializer for Users. diff --git a/apps/logs/api/views.py b/apps/logs/api/views.py index 1ddfd7bc..2c47b7a2 100644 --- a/apps/logs/api/views.py +++ b/apps/logs/api/views.py @@ -3,6 +3,7 @@ from django_filters.rest_framework import DjangoFilterBackend from rest_framework import viewsets +from rest_framework.filters import OrderingFilter from .serializers import ChangelogSerializer from ..models import Changelog @@ -16,5 +17,7 @@ class ChangelogViewSet(viewsets.ReadOnlyModelViewSet): """ queryset = Changelog.objects.all() serializer_class = ChangelogSerializer - filter_backends = [DjangoFilterBackend] - filterset_fields = ['model', 'action', "instance_pk", 'user', 'ip',] + filter_backends = [DjangoFilterBackend, OrderingFilter] + filterset_fields = ['model', 'action', "instance_pk", 'user', 'ip', ] + ordering_fields = ['timestamp', ] + ordering = ['-timestamp', ]