feat: ✨ token based auth
This commit is contained in:
parent
ef4ca9ab6a
commit
82add23844
7 changed files with 27 additions and 12 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue