api.py
698 Bytes
from rest_framework import viewsets, filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.permissions import IsAuthenticated
from core.permissions import CustomModelPermissions
from organismo.filters import OrganismoFilter
from organismo.models import Organismo
from organismo.serializers import OrganismoSerializer
class OrganismoViewSet(viewsets.ReadOnlyModelViewSet):
queryset = Organismo.objects.all()
# permission_classes = (IsAuthenticated, CustomModelPermissions)
serializer_class = OrganismoSerializer
filter_backends = (DjangoFilterBackend, filters.OrderingFilter)
filterset_class = OrganismoFilter
ordering_fields = ('id',)