♻️(backend) api teams list ordering

Give the possibility to order the teams list by
creation date.
By default the list is ordered by
creation date descending.
This commit is contained in:
Anthony LC
2024-01-31 17:03:25 +01:00
committed by Anthony LC
parent 4f0465fd32
commit 36e2dc2378
2 changed files with 61 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ from django.db.models import Func, Max, OuterRef, Q, Subquery, Value
from rest_framework import (
decorators,
exceptions,
filters,
mixins,
pagination,
response,
@@ -244,6 +245,9 @@ class TeamViewSet(
permission_classes = [permissions.AccessPermission]
serializer_class = serializers.TeamSerializer
filter_backends = [filters.OrderingFilter]
ordering_fields = ["created_at"]
ordering = ["-created_at"]
queryset = models.Team.objects.all()
def get_queryset(self):