feat: token based auth

This commit is contained in:
Tahinli 2024-06-30 17:36:29 +03:00
parent ef4ca9ab6a
commit 82add23844
7 changed files with 27 additions and 12 deletions

View file

@ -1,5 +1,6 @@
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
@ -10,7 +11,8 @@ from .serializers import UserSerializer
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
@action(detail=True, methods=['get'])
@action(detail=False, methods=['get'])
def print_this(self, request, pk=None):
print(self.get_object())