Refs #31369 -- Deprecated models.NullBooleanField in favor of BooleanField(null=True).
This commit is contained in:
parent
34a69c2458
commit
a92cc84b4a
|
@ -1929,6 +1929,14 @@ class NullBooleanField(BooleanField):
|
||||||
'invalid_nullable': _('“%(value)s” value must be either None, True or False.'),
|
'invalid_nullable': _('“%(value)s” value must be either None, True or False.'),
|
||||||
}
|
}
|
||||||
description = _("Boolean (Either True, False or None)")
|
description = _("Boolean (Either True, False or None)")
|
||||||
|
system_check_deprecated_details = {
|
||||||
|
'msg': (
|
||||||
|
'NullBooleanField is deprecated. Support for it (except in '
|
||||||
|
'historical migrations) will be removed in Django 4.0.'
|
||||||
|
),
|
||||||
|
'hint': 'Use BooleanField(null=True) instead.',
|
||||||
|
'id': 'fields.W903',
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs['null'] = True
|
kwargs['null'] = True
|
||||||
|
|
|
@ -75,6 +75,9 @@ details on these changes.
|
||||||
* Support for passing raw column aliases to ``QuerySet.order_by()`` will be
|
* Support for passing raw column aliases to ``QuerySet.order_by()`` will be
|
||||||
removed.
|
removed.
|
||||||
|
|
||||||
|
* The model ``NullBooleanField`` will be removed. A stub field will remain for
|
||||||
|
compatibility with historical migrations.
|
||||||
|
|
||||||
See the :ref:`Django 3.1 release notes <deprecated-features-3.1>` for more
|
See the :ref:`Django 3.1 release notes <deprecated-features-3.1>` for more
|
||||||
details on these changes.
|
details on these changes.
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,8 @@ Model fields
|
||||||
in historical migrations.
|
in historical migrations.
|
||||||
* **fields.W902**: ``FloatRangeField`` is deprecated and will be removed in
|
* **fields.W902**: ``FloatRangeField`` is deprecated and will be removed in
|
||||||
Django 3.1. *This check appeared in Django 2.2 and 3.0*.
|
Django 3.1. *This check appeared in Django 2.2 and 3.0*.
|
||||||
|
* **fields.W903**: ``NullBooleanField`` is deprecated. Support for it (except
|
||||||
|
in historical migrations) will be removed in Django 4.0.
|
||||||
|
|
||||||
File fields
|
File fields
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
|
@ -1182,8 +1182,11 @@ values are stored as null.
|
||||||
|
|
||||||
.. class:: NullBooleanField(**options)
|
.. class:: NullBooleanField(**options)
|
||||||
|
|
||||||
Like :class:`BooleanField` with ``null=True``. Use that instead of this field
|
Like :class:`BooleanField` with ``null=True``.
|
||||||
as it's likely to be deprecated in a future version of Django.
|
|
||||||
|
.. deprecated:: 3.1
|
||||||
|
|
||||||
|
``NullBooleanField`` is deprecated in favor of ``BooleanField(null=True)``.
|
||||||
|
|
||||||
``PositiveBigIntegerField``
|
``PositiveBigIntegerField``
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
|
@ -733,6 +733,9 @@ Miscellaneous
|
||||||
same result can be achieved by passing aliases in a
|
same result can be achieved by passing aliases in a
|
||||||
:class:`~django.db.models.expressions.RawSQL` instead beforehand.
|
:class:`~django.db.models.expressions.RawSQL` instead beforehand.
|
||||||
|
|
||||||
|
* The ``NullBooleanField`` model field is deprecated in favor of
|
||||||
|
``BooleanField(null=True)``.
|
||||||
|
|
||||||
.. _removed-features-3.1:
|
.. _removed-features-3.1:
|
||||||
|
|
||||||
Features removed in 3.1
|
Features removed in 3.1
|
||||||
|
|
|
@ -37,3 +37,18 @@ class DeprecatedFieldsTests(SimpleTestCase):
|
||||||
id='fields.E901',
|
id='fields.E901',
|
||||||
)],
|
)],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_nullbooleanfield_deprecated(self):
|
||||||
|
class NullBooleanFieldModel(models.Model):
|
||||||
|
nb = models.NullBooleanField()
|
||||||
|
|
||||||
|
model = NullBooleanFieldModel()
|
||||||
|
self.assertEqual(model.check(), [
|
||||||
|
checks.Warning(
|
||||||
|
'NullBooleanField is deprecated. Support for it (except in '
|
||||||
|
'historical migrations) will be removed in Django 4.0.',
|
||||||
|
hint='Use BooleanField(null=True) instead.',
|
||||||
|
obj=NullBooleanFieldModel._meta.get_field('nb'),
|
||||||
|
id='fields.W903',
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
|
@ -181,6 +181,7 @@ def setup(verbosity, test_labels, parallel, start_at, start_after):
|
||||||
settings.LOGGING = log_config
|
settings.LOGGING = log_config
|
||||||
settings.SILENCED_SYSTEM_CHECKS = [
|
settings.SILENCED_SYSTEM_CHECKS = [
|
||||||
'fields.W342', # ForeignKey(unique=True) -> OneToOneField
|
'fields.W342', # ForeignKey(unique=True) -> OneToOneField
|
||||||
|
'fields.W903', # NullBooleanField deprecated.
|
||||||
]
|
]
|
||||||
|
|
||||||
# Load all the ALWAYS_INSTALLED_APPS.
|
# Load all the ALWAYS_INSTALLED_APPS.
|
||||||
|
|
Loading…
Reference in New Issue