Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda