from rest_framework.response import Response from rest_framework.views import APIView from rest_framework.authentication import TokenAuthentication, SessionAuthentication from rest_framework.permissions import IsAuthenticated from .models import Employee from .serializers import EmployeeSerializer class EmployeeList(APIView): authentication_classes = [TokenAuthentication, SessionAuthentication] permission_classes = [IsAuthenticated] def get(self, request): employees = Employee.objects.all() serializer = EmployeeSerializer(employees, many=True) return Response(serializer.data)