Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
Django and DRF-DataTables - Fixing Filtering Behavior

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:

  1. filtering with "True" or "true" correctly retrieves only the records where is_active=True
  2. filtering with "False" (or any iteration where the 'F' is capitalized) correctly retrieves the records where is_active=False
  3. filtering with "false" incorrectly retrieves all records (but "fals" pulls the records where is_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'
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda