api.py 628 Bytes
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated

from .models import Organismo, Dependencia
from .serializers import OrganismoSerializer, DependenciaSerializer


class OrganismoViewSets(viewsets.ReadOnlyModelViewSet):
    queryset = Organismo.objects.all()
    serializer_class = OrganismoSerializer
    permission_classes = [IsAuthenticated, ]
    lookup_field = 'id'


class DependenciaViewSets(viewsets.ReadOnlyModelViewSet):
    queryset = Dependencia.objects.all()
    serializer_class = DependenciaSerializer
    permission_classes = [IsAuthenticated, ]
    lookup_field = 'id'