Fix API views
This commit is contained in:
parent
d2e25c0801
commit
f7688262e4
|
@ -30,7 +30,7 @@ class LabelViewSet(viewsets.ModelViewSet):
|
||||||
API endpoint that allows items to be viewed or edited.
|
API endpoint that allows items to be viewed or edited.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = Label.objects
|
queryset = Label.objects.all()
|
||||||
serializer_class = LabelSerializer
|
serializer_class = LabelSerializer
|
||||||
|
|
||||||
@action(detail=True, methods=["post"], permission_classes=[AllowAny])
|
@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.
|
API endpoint that allows items to be viewed or edited.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = Item.objects
|
queryset = Item.objects.all()
|
||||||
serializer_class = ItemSerializer
|
serializer_class = ItemSerializer
|
||||||
filter_backends = (SmartSearchFilterBackend, filters.OrderingFilter)
|
filter_backends = (SmartSearchFilterBackend, filters.OrderingFilter)
|
||||||
ordering_fields = "__all__"
|
ordering_fields = "__all__"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Item.objects.filter_roots()
|
return Item.objects.filter(**{"path__level": 1})
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
|
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
|
||||||
|
|
|
@ -3,7 +3,7 @@ from storage.models import Item, Label, Category
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
class ItemSerializer(serializers.HStoreField):
|
class ItemSerializer(serializers.ModelSerializer):
|
||||||
categories = serializers.SlugRelatedField(
|
categories = serializers.SlugRelatedField(
|
||||||
queryset=Category.objects, many=True, slug_field="name"
|
queryset=Category.objects, many=True, slug_field="name"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue