mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Remove deprecated NullBooleanField.
This commit is contained in:
parent
4d60fe5b37
commit
d6b87b0b0e
|
@ -159,14 +159,6 @@ Corresponds to `django.db.models.fields.BooleanField`.
|
||||||
|
|
||||||
**Signature:** `BooleanField()`
|
**Signature:** `BooleanField()`
|
||||||
|
|
||||||
## NullBooleanField
|
|
||||||
|
|
||||||
A boolean representation that also accepts `None` as a valid value.
|
|
||||||
|
|
||||||
Corresponds to `django.db.models.fields.NullBooleanField`.
|
|
||||||
|
|
||||||
**Signature:** `NullBooleanField()`
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# String fields
|
# String fields
|
||||||
|
|
|
@ -5,7 +5,6 @@ import functools
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
import warnings
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ from django.utils.ipv6 import clean_ipv6_address
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from pytz.exceptions import InvalidTimeError
|
from pytz.exceptions import InvalidTimeError
|
||||||
|
|
||||||
from rest_framework import ISO_8601, RemovedInDRF314Warning
|
from rest_framework import ISO_8601
|
||||||
from rest_framework.exceptions import ErrorDetail, ValidationError
|
from rest_framework.exceptions import ErrorDetail, ValidationError
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.utils import html, humanize_datetime, json, representation
|
from rest_framework.utils import html, humanize_datetime, json, representation
|
||||||
|
@ -712,23 +711,6 @@ class BooleanField(Field):
|
||||||
return bool(value)
|
return bool(value)
|
||||||
|
|
||||||
|
|
||||||
class NullBooleanField(BooleanField):
|
|
||||||
initial = None
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
warnings.warn(
|
|
||||||
"The `NullBooleanField` is deprecated and will be removed starting "
|
|
||||||
"with 3.14. Instead use the `BooleanField` field and set "
|
|
||||||
"`allow_null=True` which does the same thing.",
|
|
||||||
RemovedInDRF314Warning, stacklevel=2
|
|
||||||
)
|
|
||||||
|
|
||||||
assert 'allow_null' not in kwargs, '`allow_null` is not a valid option.'
|
|
||||||
kwargs['allow_null'] = True
|
|
||||||
|
|
||||||
super().__init__(**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
# String types...
|
# String types...
|
||||||
|
|
||||||
class CharField(Field):
|
class CharField(Field):
|
||||||
|
|
|
@ -36,7 +36,6 @@ class SimpleMetadata(BaseMetadata):
|
||||||
label_lookup = ClassLookupDict({
|
label_lookup = ClassLookupDict({
|
||||||
serializers.Field: 'field',
|
serializers.Field: 'field',
|
||||||
serializers.BooleanField: 'boolean',
|
serializers.BooleanField: 'boolean',
|
||||||
serializers.NullBooleanField: 'boolean',
|
|
||||||
serializers.CharField: 'string',
|
serializers.CharField: 'string',
|
||||||
serializers.UUIDField: 'string',
|
serializers.UUIDField: 'string',
|
||||||
serializers.URLField: 'url',
|
serializers.URLField: 'url',
|
||||||
|
|
|
@ -52,7 +52,7 @@ from rest_framework.fields import ( # NOQA # isort:skip
|
||||||
BooleanField, CharField, ChoiceField, DateField, DateTimeField, DecimalField,
|
BooleanField, CharField, ChoiceField, DateField, DateTimeField, DecimalField,
|
||||||
DictField, DurationField, EmailField, Field, FileField, FilePathField, FloatField,
|
DictField, DurationField, EmailField, Field, FileField, FilePathField, FloatField,
|
||||||
HiddenField, HStoreField, IPAddressField, ImageField, IntegerField, JSONField,
|
HiddenField, HStoreField, IPAddressField, ImageField, IntegerField, JSONField,
|
||||||
ListField, ModelField, MultipleChoiceField, NullBooleanField, ReadOnlyField,
|
ListField, ModelField, MultipleChoiceField, ReadOnlyField,
|
||||||
RegexField, SerializerMethodField, SlugField, TimeField, URLField, UUIDField,
|
RegexField, SerializerMethodField, SlugField, TimeField, URLField, UUIDField,
|
||||||
)
|
)
|
||||||
from rest_framework.relations import ( # NOQA # isort:skip
|
from rest_framework.relations import ( # NOQA # isort:skip
|
||||||
|
|
|
@ -679,9 +679,9 @@ class TestBooleanField(FieldValues):
|
||||||
assert exc_info.value.detail == expected
|
assert exc_info.value.detail == expected
|
||||||
|
|
||||||
|
|
||||||
class TestNullBooleanField(TestBooleanField):
|
class TestNullableBooleanField(TestBooleanField):
|
||||||
"""
|
"""
|
||||||
Valid and invalid values for `NullBooleanField`.
|
Valid and invalid values for `BooleanField` when `allow_null=True`.
|
||||||
"""
|
"""
|
||||||
valid_inputs = {
|
valid_inputs = {
|
||||||
'true': True,
|
'true': True,
|
||||||
|
@ -706,16 +706,6 @@ class TestNullBooleanField(TestBooleanField):
|
||||||
field = serializers.BooleanField(allow_null=True)
|
field = serializers.BooleanField(allow_null=True)
|
||||||
|
|
||||||
|
|
||||||
class TestNullableBooleanField(TestNullBooleanField):
|
|
||||||
"""
|
|
||||||
Valid and invalid values for `BooleanField` when `allow_null=True`.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@property
|
|
||||||
def field(self):
|
|
||||||
return serializers.BooleanField(allow_null=True)
|
|
||||||
|
|
||||||
|
|
||||||
# String types...
|
# String types...
|
||||||
|
|
||||||
class TestCharField(FieldValues):
|
class TestCharField(FieldValues):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user