summaryrefslogtreecommitdiff
path: root/docs/ref/forms/fields.txt
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2020-07-04 07:58:11 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-25 18:31:20 +0200
commit793bd24db6dac863ca4fb4166137f349d15f3c1c (patch)
tree88ce32e453007e4ac61c28b6b55e059c0c2542ec /docs/ref/forms/fields.txt
parentab8eccf54f52c23cd322adda3cf52617749bf14b (diff)
[3.1.x] Fixed #28009 -- Doc'd empty_value for CharField subclasses.
Backport of 91669cc566918fde4fe98f867cf4c406f64504e6 from master
Diffstat (limited to 'docs/ref/forms/fields.txt')
-rw-r--r--docs/ref/forms/fields.txt35
1 files changed, 17 insertions, 18 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 6853e1dadb..e43865ad4a 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -89,7 +89,8 @@ To specify that a field is *not* required, pass ``required=False`` to the
If a ``Field`` has ``required=False`` and you pass ``clean()`` an empty value,
then ``clean()`` will return a *normalized* empty value rather than raising
-``ValidationError``. For ``CharField``, this will be an empty string. For other
+``ValidationError``. For ``CharField``, this will return
+:attr:`~CharField.empty_value` which defaults to an empty string. For other
``Field`` classes, it might be ``None``. (This varies from field to field.)
Widgets of required form fields have the ``required`` HTML attribute. Set the
@@ -582,16 +583,15 @@ For each field, we describe the default widget used if you don't specify
.. class:: EmailField(**kwargs)
* Default widget: :class:`EmailInput`
- * Empty value: ``''`` (an empty string)
+ * Empty value: Whatever you've given as ``empty_value``.
* Normalizes to: A string.
* Uses :class:`~django.core.validators.EmailValidator` to validate that
the given value is a valid email address, using a moderately complex
regular expression.
* Error message keys: ``required``, ``invalid``
- Has two optional arguments for validation, ``max_length`` and ``min_length``.
- If provided, these arguments ensure that the string is at most or at least the
- given length.
+ Has three optional arguments ``max_length``, ``min_length``, and
+ ``empty_value`` which work just as they do for :class:`CharField`.
``FileField``
-------------
@@ -919,7 +919,7 @@ For each field, we describe the default widget used if you don't specify
.. class:: RegexField(**kwargs)
* Default widget: :class:`TextInput`
- * Empty value: ``''`` (an empty string)
+ * Empty value: Whatever you've given as ``empty_value``.
* Normalizes to: A string.
* Uses :class:`~django.core.validators.RegexValidator` to validate that
the given value matches a certain regular expression.
@@ -932,8 +932,8 @@ For each field, we describe the default widget used if you don't specify
A regular expression specified either as a string or a compiled regular
expression object.
- Also takes ``max_length``, ``min_length``, and ``strip``, which work just
- as they do for :class:`CharField`.
+ Also takes ``max_length``, ``min_length``, ``strip``, and ``empty_value``
+ which work just as they do for :class:`CharField`.
.. attribute:: strip
@@ -946,7 +946,7 @@ For each field, we describe the default widget used if you don't specify
.. class:: SlugField(**kwargs)
* Default widget: :class:`TextInput`
- * Empty value: ``''`` (an empty string)
+ * Empty value: Whatever you've given as :attr:`empty_value`.
* Normalizes to: A string.
* Uses :class:`~django.core.validators.validate_slug` or
:class:`~django.core.validators.validate_unicode_slug` to validate that
@@ -956,13 +956,17 @@ For each field, we describe the default widget used if you don't specify
This field is intended for use in representing a model
:class:`~django.db.models.SlugField` in forms.
- Takes an optional parameter:
+ Takes two optional parameters:
.. attribute:: allow_unicode
A boolean instructing the field to accept Unicode letters in addition
to ASCII letters. Defaults to ``False``.
+ .. attribute:: empty_value
+
+ The value to use to represent "empty". Defaults to an empty string.
+
``TimeField``
-------------
@@ -994,19 +998,14 @@ For each field, we describe the default widget used if you don't specify
.. class:: URLField(**kwargs)
* Default widget: :class:`URLInput`
- * Empty value: ``''`` (an empty string)
+ * Empty value: Whatever you've given as ``empty_value``.
* Normalizes to: A string.
* Uses :class:`~django.core.validators.URLValidator` to validate that the
given value is a valid URL.
* Error message keys: ``required``, ``invalid``
- Takes the following optional arguments:
-
- .. attribute:: max_length
- .. attribute:: min_length
-
- These are the same as ``CharField.max_length`` and
- ``CharField.min_length``.
+ Has three optional arguments ``max_length``, ``min_length``, and
+ ``empty_value`` which work just as they do for :class:`CharField`.
``UUIDField``
-------------