summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-05-06 10:56:28 -0400
committerTim Graham <timograham@gmail.com>2018-03-20 12:10:10 -0400
commit5fa4f40f45fcdbb7e48489ed3039a314b5c961d0 (patch)
tree272b8798d2c2a054f56d8613a42453bce30f92c0 /docs
parent73f7d1755ff1da3aac687c7b046e4b5028e505db (diff)
Fixed #29227 -- Allowed BooleanField to be null=True.
Thanks Lynn Cyrin for contributing to the patch, and Nick Pope for review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/checks.txt3
-rw-r--r--docs/ref/contrib/admin/index.txt5
-rw-r--r--docs/ref/models/fields.txt21
-rw-r--r--docs/releases/2.1.txt4
-rw-r--r--docs/topics/forms/modelforms.txt4
5 files changed, 21 insertions, 16 deletions
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 6310500d0c..1b9fa18328 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -138,7 +138,8 @@ Model fields
* **fields.E007**: Primary keys must not have ``null=True``.
* **fields.E008**: All ``validators`` must be callable.
* **fields.E100**: ``AutoField``\s must set primary_key=True.
-* **fields.E110**: ``BooleanField``\s do not accept null values.
+* **fields.E110**: ``BooleanField``\s do not accept null values. *This check
+ appeared before support for null values was added in Django 2.1.*
* **fields.E120**: ``CharField``\s must define a ``max_length`` attribute.
* **fields.E121**: ``max_length`` must be a positive integer.
* **fields.W122**: ``max_length`` is ignored when used with ``IntegerField``.
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index face1297ac..cc0cf87c8a 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -606,9 +606,8 @@ subclass::
and add that method's name to ``list_display``. (See below for more
on custom methods in ``list_display``.)
- * If the field is a ``BooleanField`` or ``NullBooleanField``, Django
- will display a pretty "on" or "off" icon instead of ``True`` or
- ``False``.
+ * If the field is a ``BooleanField``, Django will display a pretty "on" or
+ "off" icon instead of ``True`` or ``False``.
* If the string given is a method of the model, ``ModelAdmin`` or a
callable, Django will HTML-escape the output by default. To escape
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index afd0d6ff0c..adb12aac63 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -61,9 +61,6 @@ set ``blank=True`` if you wish to permit empty values in forms, as the
When using the Oracle database backend, the value ``NULL`` will be stored to
denote the empty string regardless of this attribute.
-If you want to accept :attr:`~Field.null` values with :class:`BooleanField`,
-use :class:`NullBooleanField` instead.
-
``blank``
---------
@@ -442,15 +439,18 @@ case it can't be included in a :class:`~django.forms.ModelForm`.
A true/false field.
-The default form widget for this field is a
-:class:`~django.forms.CheckboxInput`.
-
-If you need to accept :attr:`~Field.null` values then use
-:class:`NullBooleanField` instead.
+The default form widget for this field is :class:`~django.forms.CheckboxInput`,
+or :class:`~django.forms.NullBooleanSelect` if :attr:`null=True <Field.null>`.
The default value of ``BooleanField`` is ``None`` when :attr:`Field.default`
isn't defined.
+.. versionchanged:: 2.1
+
+ In older versions, this field doesn't permit ``null=True``, so you have to
+ use :class:`NullBooleanField` instead. Using the latter is now discouraged
+ as it's likely to be deprecated in a future version of Django.
+
``CharField``
-------------
@@ -1008,9 +1008,8 @@ values are stored as null.
.. class:: NullBooleanField(**options)
-Like a :class:`BooleanField`, but allows ``NULL`` as one of the options. Use
-this instead of a :class:`BooleanField` with ``null=True``. The default form
-widget for this field is a :class:`~django.forms.NullBooleanSelect`.
+Like :class:`BooleanField` with ``null=True``. Use that instead of this field
+as it's likely to be deprecated in a future version of Django.
``PositiveIntegerField``
------------------------
diff --git a/docs/releases/2.1.txt b/docs/releases/2.1.txt
index 4d8a9a1d42..ec2a3266a1 100644
--- a/docs/releases/2.1.txt
+++ b/docs/releases/2.1.txt
@@ -223,6 +223,10 @@ Models
* :meth:`.QuerySet.order_by` and :meth:`distinct(*fields) <.QuerySet.distinct>`
now support using field transforms.
+* :class:`~django.db.models.BooleanField` can now be ``null=True``. This is
+ encouraged instead of :class:`~django.db.models.NullBooleanField`, which will
+ likely be deprecated in the future.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 553271e598..ec7c7a0587 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -67,7 +67,9 @@ Model field Form field
``True`` on the model field, otherwise not
represented in the form.
-:class:`BooleanField` :class:`~django.forms.BooleanField`
+:class:`BooleanField` :class:`~django.forms.BooleanField`, or
+ :class:`~django.forms.NullBooleanField` if
+ ``null=True``.
:class:`CharField` :class:`~django.forms.CharField` with
``max_length`` set to the model field's