philipn/django-rest-framework-filters

lt gt

jmpmcmanus opened this issue · 2 comments

I'm trying to use lt and gt. My filter is:

import rest_framework_filters as filters
from .models import testdata_Model

class TestdataFilter(filters.FilterSet):
    class Meta:
        model = testdata_Model
        fields = {
            'concentrat':  ['exact', 'lt', 'gt', 'lte', 'gte']
        }

# view
class testdata_View(viewsets.ModelViewSet):
    queryset = testdata_Model.objects.all()
    serializer_class = testdata_Serializer
    filter_class = TestdataFilter

when I try:

http://localhost:8000/api/testdata_Model/?concentrat__gt=2

it does not subset the data?

Hi @jmpmcmanus. Are you using the RestFrameworkFilterBackend?

I forgot to put:

'DEFAULT_FILTER_BACKENDS': (
    'rest_framework_filters.backends.ComplexFilterBackend',
),

in settings.py. Now it is working! Thanks!