[Answered ]-How to implement date range filter in django-filters

1👍

I think you need to create MetaDataFilter.

from django_filters import rest_framework as filters

class MetaDataFilter(filters.FilterSet):
    upload_date = filters.DateFromToRangeFilter()

    class Meta:
        model = MetaData
        fields = ['upload_date']

In the view, you can set the filterset_class

class FetchMetaData(ListCreateAPIView):
    ...
    filterset_class = MetaDataFilter

Then, the api url should be .../filterMetadata/?upload_date_before=2022-01-05&upload_date_after=2022-01-05.

Leave a comment