I use the Django REST Framework, and I use filters to filter a set of requests.
http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-query-parameters
like this
http://example.com/api/products/4675/?category=clothing&max_price=10.00
But I saw that if there is an error in the filters or the query parameters do not exist, then it displays all very bad results.
I do not want any results if there is a problem with the query parameters, because sometimes I do not know if this works or not.
EDIT
This is my code.
class userFilter(django_filters.FilterSet): strict = True class Meta: model = User fields = ('is_active', 'is_archived', 'age')
REST
class UserListCreateView(generics.ListCreateAPIView): queryset = User.objects.filter(is_archived=False) ordering_fields = ('is_active') filter_class = userFilter
These are REST settings
REST_FRAMEWORK = { 'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.HyperlinkedModelSerializer', 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.IsAuthenticated', ], 'DEFAULT_FILTER_BACKENDS': ( 'rest_framework.filters.DjangoFilterBackend', 'rest_framework.filters.SearchFilter', 'rest_framework.filters.OrderingFilter', ), # 'PAGINATE_BY': 1, 'PAGINATE_BY_PARAM': 'page_size', 'MAX_PAGINATE_BY': 100, 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication', ) }
source share