4đź‘Ť
Django has NullBooleanField
this is a subclass of a BooleanField
but where both null=True
and blank=True
hold.
In django-2.1, the documentation mentions that null=True
is allowed for a BooleanField
, and that the NullBooleanField
will probably get deprecated:
In older versions, this field doesn’t permit
null=True
, so you have to
useNullBooleanField
instead. Using the latter is now discouraged as
it’s likely to be deprecated in a future version of Django.
In the more early versions of Django, it was thus impossible to write BooleanField(null=True)
, but that behavior has changed.
Regardless what will be used, the idea is that the database can store three possible values: TRUE
(mapping to True
), FALSE
(mapping to False
), and NULL
(mapping to None
).
Note that just like CharField
s, you can set choices
to let the values map on more “sensical” displays.
- [Django]-Django – bulk update arrayfield rows postgres
- [Django]-Cannot urlencode() after storing QueryDict in session
- [Django]-Django ping google http error