Closed
Description
Discussed in #8269
Originally posted by math-a3k November 29, 2021
Current code for BooleanField does not fully supports for null values as the default inital is set to False. This makes unsuitable for replacing NullBooleanField as it is stated in the deprecation warning.
How to reproduce:
from rest_framework import serializers
from django.conf import settings
from django.http import QueryDict
settings.configure()
class TestSerializer(serializers.Serializer):
archived = serializers.BooleanField(allow_null=True)
serializer = TestSerializer(data=QueryDict(''))
assert serializer.is_valid()
assert serializer.validated_data == {'archived': None}
The proposed fix is here: math-a3k@7af79a0
and should be ready to merge / pull request if you deem so