1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Improve REST API with filters

This commit is contained in:
Yohann D'ANELLO
2020-03-11 11:15:03 +01:00
parent bc97eb1eb4
commit 417cd5da04
15 changed files with 78 additions and 36 deletions

View File

@ -1,6 +1,7 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import viewsets
from .serializers import ChangelogSerializer
@ -15,3 +16,5 @@ class ChangelogViewSet(viewsets.ModelViewSet):
"""
queryset = Changelog.objects.all()
serializer_class = ChangelogSerializer
filter_backends = [DjangoFilterBackend]
filterset_fields = ['model', 'action', "instance_pk", 'user', 'ip',]