How can I do a range filter for dates and number in Django REST Framework? Other filters (lt, gt etc.) work fine. I tried many variants such as:
import rest_framework_filters as filters
class OrderFilter(filters.FilterSet):
total_price__range = filters.RangeFilter(name='total_price')
created_at__range = filters.DateFromToRangeFilter(name='created_at')
....
class Meta:
model = Order
fields = {
'created_at__range': ['__all__'],
'total_price__range': ['__all__'],
...
}
class OrderViewSet(BaseViewSet, viewsets.ModelViewSet):
filter_class = OrderFilter
....
In the browsable api there are to fields when I click on bottom "Filters", Then url looks like:
/orders/?created_at__range_0=2017-05-22&created_at__range_1=2017-05-22
and it doesn't work. I need something like
/orders/?created_at__range=2017-05-22,2017-05-24
and same with integer:
/orders/?total_price__range=1000,2000
It was described here .
What am I doing wrong?