tJango/user/views.py
2024-06-30 17:36:29 +03:00

18 lines
564 B
Python

from django.shortcuts import render
from rest_framework import viewsets
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):
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())