I basically need something like /?status=[active,processed]
or /?status=active,processed
My current setting is: 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)
and it's only filtering one value correctly (/?status=active
)
I think there is no inbuilt functionality for that. But you can implement a custom filter to do that. This custom filter you can use in your filterset.
import django_filters as df
class InListFilter(df.Filter):
"""
Expects a comma separated list
filters values in list
"""
def filter(self, qs, value):
if value:
return qs.filter(**{self.name+'__in': value.split(',')})
return qs
class MyFilterSet(df.FilterSet):
status = InListFilter(name='status')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With