feat: ✨ readonly viewset
This commit is contained in:
parent
69fba80de4
commit
a73553ab81
8 changed files with 69 additions and 27 deletions
|
@ -1,18 +1,10 @@
|
|||
from django.shortcuts import render
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
from rest_framework.permissions import IsAuthenticatedOrReadOnly
|
||||
from rest_framework.decorators import action
|
||||
from .models import User
|
||||
from .serializers import UserSerializer
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class UserViewSet(viewsets.ModelViewSet):
|
||||
class UserViewSet(ReadOnlyModelViewSet):
|
||||
queryset = User.objects.all()
|
||||
serializer_class = UserSerializer
|
||||
permission_classes = [IsAuthenticatedOrReadOnly]
|
||||
|
||||
@action(detail=False, methods=['get'])
|
||||
def print_this(self, request, pk=None):
|
||||
print(self.get_object())
|
||||
# permission_classes = [IsAuthenticatedOrReadOnly]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue