Skip to content

allow_null is not fully supported in BooleanField #8427

@math-a3k

Description

@math-a3k

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy