mirror of https://github.com/django/django.git
[1.6.x] Fixed #22145 -- Clarified docs on Field.blank and Field.null options.
Thanks skipjack at peru.com for the suggestion.
Backport of 3390550f6f
from master
This commit is contained in:
parent
dde67de0f6
commit
f2b513c9e8
|
@ -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::
|
||||
|
||||
|
|
Loading…
Reference in New Issue