Deprecated NullBooleanField

NullBooleanField is deprecated and will be removed a future version of Django.

NullBooleanField is like BooleanField with null=True.

Historically the only values BooleanField accepted was True and False. BooleanField didn't permit null=True. If null was a valid value then NullBooleanField was used instead.

So in practice, do this


class SomeModel(models.Model):
    some_field = models.BooleanField(null=True)

Instead of this


class SomeModel(models.Model):
    some_field = models.NullBooleanField()

Are you affected? Check with
pip install django-doctor
.

Configuring this check

Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code deprecated-nullboolean-field in your pyproject.toml file.

Read more about configuring Django Doctor.