Add filter backend for storage model in API
This commit is contained in:
parent
a73fba0f1b
commit
e6eb9346a8
@ -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,6 +43,8 @@ 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()
|
||||
|
@ -41,6 +41,7 @@ INSTALLED_APPS = [
|
||||
'parts.apps.PartsConfig',
|
||||
'api.apps.ApiConfig',
|
||||
'rest_framework.authtoken',
|
||||
'django_filters',
|
||||
'qr_code',
|
||||
'rest_framework',
|
||||
'crispy_forms',
|
||||
|
@ -58,6 +58,7 @@ INSTALLED_APPS = [
|
||||
'parts.apps.PartsConfig',
|
||||
'api.apps.ApiConfig',
|
||||
'rest_framework.authtoken',
|
||||
'django_filters',
|
||||
'qr_code',
|
||||
'rest_framework',
|
||||
'crispy_forms',
|
||||
|
Loading…
Reference in New Issue
Block a user