api.py 659 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().order_by('id')
    serializer_class = OrganismoSerializer
    permission_classes = [IsAuthenticated, ]
    lookup_field = 'id'


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