diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index 078ca6c..78722a0 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -18,6 +18,7 @@ from rest_framework.authtoken.models import Token from rest_framework.throttling import AnonRateThrottle from rest_framework.decorators import action from rest_framework import filters +import django_filters.rest_framework # Create your views here. class UserViewSet(viewsets.ReadOnlyModelViewSet): @@ -42,7 +43,9 @@ class PartsStorageViewSet(viewsets.ModelViewSet): queryset = parts_models.Storage.objects.all() serializer_class = StorageSerializer permission_classes = [permissions.DjangoModelPermissions] - + filter_backends = [django_filters.rest_framework.DjangoFilterBackend] + filterset_fields = ['id', 'name', 'parent_storage'] + class PartsComponentViewSet(viewsets.ModelViewSet): queryset = parts_models.Component.objects.all() serializer_class = ComponentSerializer diff --git a/shimatta_kenkyusho/shimatta_kenkyusho/settings.py b/shimatta_kenkyusho/shimatta_kenkyusho/settings.py index a585807..ecb4816 100644 --- a/shimatta_kenkyusho/shimatta_kenkyusho/settings.py +++ b/shimatta_kenkyusho/shimatta_kenkyusho/settings.py @@ -41,6 +41,7 @@ INSTALLED_APPS = [ 'parts.apps.PartsConfig', 'api.apps.ApiConfig', 'rest_framework.authtoken', + 'django_filters', 'qr_code', 'rest_framework', 'crispy_forms', diff --git a/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py b/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py index 177ee0a..de1391f 100644 --- a/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py +++ b/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py @@ -58,6 +58,7 @@ INSTALLED_APPS = [ 'parts.apps.PartsConfig', 'api.apps.ApiConfig', 'rest_framework.authtoken', + 'django_filters', 'qr_code', 'rest_framework', 'crispy_forms',