Files
LibraryApp/backend/apps/shelves/views.py
2026-03-11 23:20:03 +01:00

20 lines
621 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 Shelf.objects.filter(user_id=self.request.user.pk)