summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClifford Gama <cliffygamy@gmail.com>2024-08-14 12:42:33 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-08-20 08:09:39 +0200
commitca1318988c68f623ab12ab4ddb04eabb8afe5a33 (patch)
tree16ed46aa92d95d1253e4f4623b6edf179ccca459 /docs
parent0ebed5fa95f53b87383901bbd9341ef3c974344f (diff)
Fixed #35671 -- Clarified string-based fields behavior when null=False.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/fields.txt16
1 files changed, 9 insertions, 7 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index c83b50ab7e..612949ab4a 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -43,13 +43,15 @@ If ``True``, Django will store empty values as ``NULL`` in the database. Default
is ``False``.
Avoid using :attr:`~Field.null` on string-based fields such as
-:class:`CharField` and :class:`TextField`. If a string-based field has
-``null=True``, that means it has two possible values for "no data": ``NULL``,
-and the empty string. In most cases, it's redundant to have two possible values
-for "no data;" the Django convention is to use the empty string, not
-``NULL``. One exception is when a :class:`CharField` has both ``unique=True``
-and ``blank=True`` set. In this situation, ``null=True`` is required to avoid
-unique constraint violations when saving multiple objects with blank values.
+:class:`CharField` and :class:`TextField`. The Django convention is to use an
+empty string, not ``NULL``, as the "no data" state for string-based fields. If a
+string-based field has ``null=False``, empty strings can still be saved for "no
+data". If a string-based field has ``null=True``, that means it has two possible
+values for "no data": ``NULL``, and the empty string. In most cases, it's
+redundant to have two possible values for "no data". One exception is when a
+:class:`CharField` has both ``unique=True`` and ``blank=True`` set. In this
+situation, ``null=True`` is required to avoid unique constraint violations when
+saving multiple objects with blank values.
For both string-based and non-string-based fields, you will also need to
set ``blank=True`` if you wish to permit empty values in forms, as the