From 3390550f6f645f82354eaffa1d3c89dfa041f1aa Mon Sep 17 00:00:00 2001 From: navneet suman Date: Tue, 25 Feb 2014 21:14:46 +0530 Subject: [PATCH] Fixed #22145 -- Clarified docs on Field.blank and Field.null options. Thanks skipjack at peru.com for the suggestion. --- docs/ref/models/fields.txt | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index cecfddca5f..7c95f0fd70 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -39,19 +39,17 @@ The following arguments are available to all field types. All are optional. If ``True``, Django will store empty values as ``NULL`` in the database. Default is ``False``. -Note that empty string values will always get stored as empty strings, not as -``NULL``. Only use ``null=True`` for non-string fields such as integers, -booleans and dates. For both types of fields, you will also need to set -``blank=True`` if you wish to permit empty values in forms, as the -:attr:`~Field.null` parameter only affects database storage (see -:attr:`~Field.blank`). - Avoid using :attr:`~Field.null` on string-based fields such as -:class:`CharField` and :class:`TextField` unless you have an excellent reason. -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;" Django convention is to use the empty -string, not ``NULL``. +:class:`CharField` and :class:`TextField` because empty string values will +always be stored as empty strings, not as ``NULL``. 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``. + +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 +:attr:`~Field.null` parameter only affects database storage +(see :attr:`~Field.blank`). .. note::