add filterset search to page

This commit is contained in:
2025-06-07 12:23:11 +03:30
parent 4bd89aee8b
commit 5414c6c1dc
2 changed files with 7 additions and 0 deletions

View File

@@ -155,6 +155,10 @@ REST_FRAMEWORK = {
'rest_framework.authentication.SessionAuthentication',
'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',
"DEFAULT_PAGINATION_CLASS": 'apps.core.pagination.CustomPageNumberPagination',
"PAGE_SIZE": 20,

View File

@@ -16,6 +16,7 @@ from apps.authorization.models import (
)
from rest_framework import viewsets
from django.db import transaction
from rest_framework import filters
class RoleViewSet(viewsets.ModelViewSet):
@@ -30,6 +31,8 @@ class PageViewSet(viewsets.ModelViewSet):
queryset = Page.objects.all()
serializer_class = PageSerializer
filter_backends = [filters.SearchFilter]
search_fields = ['name', 'code']
class PermissionViewSet(viewsets.ModelViewSet):