diff --git a/api/views.py b/api/views.py index bf76744..2c902c8 100644 --- a/api/views.py +++ b/api/views.py @@ -13,6 +13,7 @@ class ContainerViewSet(viewsets.ModelViewSet): queryset = Container.objects.all().order_by('named_id') serializer_class = ContainerSerializer permission_classes = [permissions.IsAuthenticated] + filterset_fields = ['named_id', 'color'] class ContainerTypeViewSet(viewsets.ModelViewSet): @@ -22,6 +23,7 @@ class ContainerTypeViewSet(viewsets.ModelViewSet): queryset = ContainerType.objects.all() serializer_class = ContainerTypeSerializer permission_classes = [permissions.IsAuthenticated] + filterset_fields = ['named_id', 'has_cover', 'contains_container'] class AssetViewSet(viewsets.ModelViewSet): @@ -31,6 +33,8 @@ class AssetViewSet(viewsets.ModelViewSet): queryset = Asset.objects.all().order_by('named_id') serializer_class = AssetSerializer permission_classes = [permissions.IsAuthenticated] + filterset_fields = ['named_id', 'quantity'] + class GtinProductViewSet(viewsets.ModelViewSet): @@ -40,3 +44,5 @@ class GtinProductViewSet(viewsets.ModelViewSet): queryset = GtinProduct.objects.all().order_by('gtin') serializer_class = GtinProductSerializer permission_classes = [permissions.IsAuthenticated] + filterset_fields = ['gtin'] + diff --git a/homelog/settings.py b/homelog/settings.py index 01adf0b..4075935 100644 --- a/homelog/settings.py +++ b/homelog/settings.py @@ -176,5 +176,6 @@ REST_FRAMEWORK = { 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ], 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', - 'PAGE_SIZE': 10 + 'PAGE_SIZE': 10, + 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'] }