Files
LibraryApp/backend/apps/shelves/views.py
2026-03-12 23:24:14 +01:00

22 lines
643 B
Python

from django.shortcuts import render
from apps.shelves.models import Shelf
from apps.shelves.serializers import ShelfSerializer
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated
from rest_framework_simplejwt.authentication import JWTAuthentication
class ShelvesViewSet(viewsets.ModelViewSet):
queryset = Shelf.objects.select_related("user")
serializer_class = ShelfSerializer
authentication_classes = [JWTAuthentication]
permission_classes = [IsAuthenticated]
def get_queryset(self):
return self.queryset.filter(
user_id=self.request.user.pk
)