123456789101112131415161718192021222324 |
- from django.contrib.auth.models import User, Group
- from rest_framework import viewsets
- from rest_framework import permissions
- from .serializers import UserSerializer, GroupSerializer
- from rest_framework.views import APIView
- from rest_framework_api_key.permissions import HasAPIKey
- class UserViewSet(viewsets.ModelViewSet):
- """
- API endpoint that allows users to be viewed or edited.
- """
- queryset = User.objects.all().order_by('-date_joined')
- serializer_class = UserSerializer
- permission_classes = [HasAPIKey]
- class GroupViewSet(viewsets.ModelViewSet):
- """
- API endpoint that allows groups to be viewed or edited.
- """
- queryset = Group.objects.all()
- serializer_class = GroupSerializer
- permission_classes = [HasAPIKey]
|