tJango/user/views.py

19 lines
564 B
Python
Raw Normal View History

2024-06-29 03:03:21 +03:00
from django.shortcuts import render
from rest_framework import viewsets
2024-06-30 17:36:29 +03:00
from rest_framework.permissions import IsAuthenticatedOrReadOnly
2024-06-29 03:03:21 +03:00
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
2024-06-30 17:36:29 +03:00
permission_classes = [IsAuthenticatedOrReadOnly]
2024-06-29 03:03:21 +03:00
2024-06-30 17:36:29 +03:00
@action(detail=False, methods=['get'])
2024-06-29 03:03:21 +03:00
def print_this(self, request, pk=None):
print(self.get_object())