mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #4960 -- Added "strip" option to CharField
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user