@@ -89,7 +89,8 @@ To specify that a field is *not* required, pass ``required=False`` to the
8989
9090If a ``Field`` has ``required=False`` and you pass ``clean()`` an empty value,
9191then ``clean()`` will return a *normalized* empty value rather than raising
92- ``ValidationError``. For ``CharField``, this will be an empty string. For other
92+ ``ValidationError``. For ``CharField``, this will return
93+ :attr:`~CharField.empty_value` which defaults to an empty string. For other
9394``Field`` classes, it might be ``None``. (This varies from field to field.)
9495
9596Widgets 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
582583.. class:: EmailField(**kwargs)
583584
584585 * Default widget: :class:`EmailInput`
585- * Empty value: ``''`` (an empty string)
586+ * Empty value: Whatever you've given as ``empty_value``.
586587 * Normalizes to: A string.
587588 * Uses :class:`~django.core.validators.EmailValidator` to validate that
588589 the given value is a valid email address, using a moderately complex
589590 regular expression.
590591 * Error message keys: ``required``, ``invalid``
591592
592- Has two optional arguments for validation, ``max_length`` and ``min_length``.
593- If provided, these arguments ensure that the string is at most or at least the
594- given length.
593+ Has three optional arguments ``max_length``, ``min_length``, and
594+ ``empty_value`` which work just as they do for :class:`CharField`.
595595
596596``FileField``
597597-------------
@@ -919,7 +919,7 @@ For each field, we describe the default widget used if you don't specify
919919.. class:: RegexField(**kwargs)
920920
921921 * Default widget: :class:`TextInput`
922- * Empty value: ``''`` (an empty string)
922+ * Empty value: Whatever you've given as ``empty_value``.
923923 * Normalizes to: A string.
924924 * Uses :class:`~django.core.validators.RegexValidator` to validate that
925925 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
932932 A regular expression specified either as a string or a compiled regular
933933 expression object.
934934
935- Also takes ``max_length``, ``min_length``, and ``strip``, which work just
936- as they do for :class:`CharField`.
935+ Also takes ``max_length``, ``min_length``, ``strip``, and ``empty_value``
936+ which work just as they do for :class:`CharField`.
937937
938938 .. attribute:: strip
939939
@@ -946,7 +946,7 @@ For each field, we describe the default widget used if you don't specify
946946.. class:: SlugField(**kwargs)
947947
948948 * Default widget: :class:`TextInput`
949- * Empty value: ``''`` (an empty string)
949+ * Empty value: Whatever you've given as :attr:`empty_value`.
950950 * Normalizes to: A string.
951951 * Uses :class:`~django.core.validators.validate_slug` or
952952 :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
956956 This field is intended for use in representing a model
957957 :class:`~django.db.models.SlugField` in forms.
958958
959- Takes an optional parameter :
959+ Takes two optional parameters :
960960
961961 .. attribute:: allow_unicode
962962
963963 A boolean instructing the field to accept Unicode letters in addition
964964 to ASCII letters. Defaults to ``False``.
965965
966+ .. attribute:: empty_value
967+
968+ The value to use to represent "empty". Defaults to an empty string.
969+
966970``TimeField``
967971-------------
968972
@@ -994,19 +998,14 @@ For each field, we describe the default widget used if you don't specify
994998.. class:: URLField(**kwargs)
995999
9961000 * Default widget: :class:`URLInput`
997- * Empty value: ``''`` (an empty string)
1001+ * Empty value: Whatever you've given as ``empty_value``.
9981002 * Normalizes to: A string.
9991003 * Uses :class:`~django.core.validators.URLValidator` to validate that the
10001004 given value is a valid URL.
10011005 * Error message keys: ``required``, ``invalid``
10021006
1003- Takes the following optional arguments:
1004-
1005- .. attribute:: max_length
1006- .. attribute:: min_length
1007-
1008- These are the same as ``CharField.max_length`` and
1009- ``CharField.min_length``.
1007+ Has three optional arguments ``max_length``, ``min_length``, and
1008+ ``empty_value`` which work just as they do for :class:`CharField`.
10101009
10111010``UUIDField``
10121011-------------
0 commit comments