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.

If we spot this issue in your GitHub pull request we give this advice:

models.pymaintainabilitymedium
class CommentModel(models.Model):
-
    is_active = models.NullBooleanField()
+
    is_active = models.BooleanField(null=True)
    body = models.TextField()

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

Read more
Protect your pull requests from over 40 types of common Django technical debts with our GitHub code review bot.

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.