I am using DRF-DataTables to create a browsable table on the client side.
The model I am working with contains some nullable boolean fields like so:
models.py
class Record(...):
name = models.CharField(..., blank=True, null=True)
is_active = models.BooleanField(blank=True, null=True)
The table is rendered with serverside=true, however there is some unwanted behavior when trying to filter on the is_active column:
is_active=Trueis_active=Falseis_active=False)Furthermore - there does not seem to be anyway to filter for the records where is_active=None or name=None
An idea solution would be to override the filtering logic by writing my own FilterSet, however when trying to follow the docs I run into this error:
views.py
class RecordGlobalFilter(...):
name = GlobalCharFilter(lookup_expr='icontains')
class Meta:
model = Record
fields = '__all__'
class RecordViewSet(...):
...
filter_backends = [DatatablesFilterBackend]
filterset_class = RecordFilter
The error:
AttributeError: type object 'RecordFilter' has no attribute '_meta'