feat: ✨ token based auth
This commit is contained in:
parent
ef4ca9ab6a
commit
82add23844
7 changed files with 27 additions and 12 deletions
18
user/migrations/0002_alter_user_username.py
Normal file
18
user/migrations/0002_alter_user_username.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 5.0.6 on 2024-06-29 23:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('user', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='username',
|
||||
field=models.CharField(max_length=15, unique=True),
|
||||
),
|
||||
]
|
|
@ -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