from django_filters import rest_framework as filters


class MyJsonListFilter(filters.CharFilter):
    def filter(self, qs, value):
        
        if value in ['all', '']:
            return qs
        elif ',' in value:
            value_l = value.split(',')
            qsx = qs.none()
            for i in value_l:
                kv = {f"{self.field_name}__contains": i}
                qsx = qsx | qs.filter(**kv)
            return qsx
        else:
            kv = {f"{self.field_name}__contains": value}
            return qs.filter(**kv)
