♻️(backend) api resources list ordering
Give the possibility to order the resources list by creation date (documents / templates). By default the list is ordered by creation date descending.
This commit is contained in:
@@ -12,6 +12,7 @@ from django.http import FileResponse
|
||||
from rest_framework import (
|
||||
decorators,
|
||||
exceptions,
|
||||
filters,
|
||||
mixins,
|
||||
pagination,
|
||||
status,
|
||||
@@ -138,6 +139,10 @@ class UserViewSet(
|
||||
class ResourceViewsetMixin:
|
||||
"""Mixin with methods common to all resource viewsets that are managed with accesses."""
|
||||
|
||||
filter_backends = [filters.OrderingFilter]
|
||||
ordering_fields = ["created_at"]
|
||||
ordering = ["-created_at"]
|
||||
|
||||
def get_queryset(self):
|
||||
"""Custom queryset to get user related resources."""
|
||||
queryset = super().get_queryset()
|
||||
|
||||
Reference in New Issue
Block a user