summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCurtis <curtis@tinbrain.net>2015-02-05 23:26:15 +1100
committerTim Graham <timograham@gmail.com>2015-07-01 17:47:05 -0400
commit11cac1bd8ef7546ca32d9969d4348bf412dc6664 (patch)
tree4a83b9056acdf88c601e73a3b3b02876fe022eca /docs
parentb535eb3fcb6768b2ee2a900c3ca7217b5aecffa6 (diff)
Fixed #4960 -- Added "strip" option to CharField
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/fields.txt20
-rw-r--r--docs/releases/1.9.txt11
2 files changed, 27 insertions, 4 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index dbade5c5d9..c4a40021d0 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -361,7 +361,7 @@ For each field, we describe the default widget used if you don't specify
Otherwise, all inputs are valid.
* Error message keys: ``required``, ``max_length``, ``min_length``
- Has two optional arguments for validation:
+ Has three optional arguments for validation:
.. attribute:: max_length
.. attribute:: min_length
@@ -369,6 +369,13 @@ For each field, we describe the default widget used if you don't specify
If provided, these arguments ensure that the string is at most or at least
the given length.
+ .. attribute:: strip
+
+ .. versionadded:: 1.9
+
+ If ``True`` (default), the value will be stripped of leading and
+ trailing whitespace.
+
``ChoiceField``
~~~~~~~~~~~~~~~
@@ -824,8 +831,15 @@ 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`` and ``min_length``, which work just as they do for
- ``CharField``.
+ Also takes ``max_length``, ``min_length``, and ``strip``, which work just
+ as they do for ``CharField``.
+
+ .. attribute:: strip
+
+ .. versionadded:: 1.9
+
+ Defaults to ``False``. If enabled, stripping will be applied before the
+ regex validation.
.. deprecated:: 1.8
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index 48c850f9a7..b1a799f8bf 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -302,6 +302,11 @@ Forms
* You can now :ref:`specify keyword arguments <custom-formset-form-kwargs>`
that you want to pass to the constructor of forms in a formset.
+* :class:`~django.forms.CharField` now accepts a
+ :attr:`~django.forms.CharField.strip` argument to strip input data of leading
+ and trailing whitespace. As this defaults to ``True`` this is different
+ behavior from previous releases.
+
Generic Views
^^^^^^^^^^^^^
@@ -552,7 +557,7 @@ Database backend API
SQLite backend to add time lookups (hour, minute, second) to
:class:`~django.db.models.TimeField`, and may be needed by third-party
database backends.
-
+
* The ``DatabaseOperations.datetime_cast_sql()`` method (not to be confused
with ``DatabaseOperations.datetime_cast_date_sql()`` mentioned above)
has been removed. This method served to format dates on Oracle long
@@ -822,6 +827,10 @@ Miscellaneous
be serialized contains any control characters not allowed in the XML 1.0
standard, the serialization will fail with a :exc:`ValueError`.
+* :class:`~django.forms.CharField` now strips input of leading and trailing
+ whitespace by default. This can be disabled by setting the new
+ :attr:`~django.forms.CharField.strip` argument to ``False``.
+
.. _deprecated-features-1.9:
Features deprecated in 1.9