add filterset search to page
This commit is contained in:
@@ -155,6 +155,10 @@ REST_FRAMEWORK = {
|
|||||||
'rest_framework.authentication.SessionAuthentication',
|
'rest_framework.authentication.SessionAuthentication',
|
||||||
'rest_framework.authentication.BasicAuthentication',
|
'rest_framework.authentication.BasicAuthentication',
|
||||||
),
|
),
|
||||||
|
'DEFAULT_FILTER_BACKENDS': [
|
||||||
|
'django_filters.rest_framework.DjangoFilterBackend',
|
||||||
|
'rest_framework.filters.SearchFilter',
|
||||||
|
],
|
||||||
'EXCEPTION_HANDLER': 'apps.core.error_handler.custom_exception_handler',
|
'EXCEPTION_HANDLER': 'apps.core.error_handler.custom_exception_handler',
|
||||||
"DEFAULT_PAGINATION_CLASS": 'apps.core.pagination.CustomPageNumberPagination',
|
"DEFAULT_PAGINATION_CLASS": 'apps.core.pagination.CustomPageNumberPagination',
|
||||||
"PAGE_SIZE": 20,
|
"PAGE_SIZE": 20,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from apps.authorization.models import (
|
|||||||
)
|
)
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from rest_framework import filters
|
||||||
|
|
||||||
|
|
||||||
class RoleViewSet(viewsets.ModelViewSet):
|
class RoleViewSet(viewsets.ModelViewSet):
|
||||||
@@ -30,6 +31,8 @@ class PageViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = Page.objects.all()
|
queryset = Page.objects.all()
|
||||||
serializer_class = PageSerializer
|
serializer_class = PageSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['name', 'code']
|
||||||
|
|
||||||
|
|
||||||
class PermissionViewSet(viewsets.ModelViewSet):
|
class PermissionViewSet(viewsets.ModelViewSet):
|
||||||
|
|||||||
Reference in New Issue
Block a user