From f7688262e4d2aa7e8cfb5fbcafa13b2ec79884a0 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Mon, 17 Jul 2023 15:46:00 +0200 Subject: [PATCH] Fix API views --- storage/apiviews.py | 6 +++--- storage/serializers.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/apiviews.py b/storage/apiviews.py index 36bd6ce..fbc2f3b 100644 --- a/storage/apiviews.py +++ b/storage/apiviews.py @@ -30,7 +30,7 @@ class LabelViewSet(viewsets.ModelViewSet): API endpoint that allows items to be viewed or edited. """ - queryset = Label.objects + queryset = Label.objects.all() serializer_class = LabelSerializer @action(detail=True, methods=["post"], permission_classes=[AllowAny]) @@ -47,13 +47,13 @@ class ItemViewSet(viewsets.ModelViewSet): API endpoint that allows items to be viewed or edited. """ - queryset = Item.objects + queryset = Item.objects.all() serializer_class = ItemSerializer filter_backends = (SmartSearchFilterBackend, filters.OrderingFilter) ordering_fields = "__all__" def get_queryset(self): - return Item.objects.filter_roots() + return Item.objects.filter(**{"path__level": 1}) def get_object(self): lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field diff --git a/storage/serializers.py b/storage/serializers.py index dbe96c2..cef102e 100644 --- a/storage/serializers.py +++ b/storage/serializers.py @@ -3,7 +3,7 @@ from storage.models import Item, Label, Category from rest_framework import serializers -class ItemSerializer(serializers.HStoreField): +class ItemSerializer(serializers.ModelSerializer): categories = serializers.SlugRelatedField( queryset=Category.objects, many=True, slug_field="name" )