summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2014-03-23 01:08:04 +0700
committerTim Graham <timograham@gmail.com>2014-03-24 07:21:32 -0400
commit7ac8380799eedb374621317b62ccf026d86ea245 (patch)
tree45f289c8ed60df14ce6ca2312f6ad5232b85480e /docs
parent3f7615cddc69235d466fb680fb05869f2a80d1e4 (diff)
Fixed #22318 -- Added Form.has_error() to easily check if a given error has happened.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/api.txt11
-rw-r--r--docs/releases/1.8.txt3
2 files changed, 14 insertions, 0 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index c4d0b18b0f..cb6cf7a51b 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -182,6 +182,17 @@ when defining form errors.
Note that ``Form.add_error()`` automatically removes the relevant field from
``cleaned_data``.
+.. method:: Form.has_error(field, code=None)
+
+.. versionadded:: 1.8
+
+This method returns a boolean designating whether a field has an error with
+a specific error ``code``. If ``code`` is ``None``, it will return ``True``
+if the field contains any errors at all.
+
+To check for non-field errors use
+:data:`~django.core.exceptions.NON_FIELD_ERRORS` as the ``field`` parameter.
+
Behavior of unbound forms
~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 2214b77839..10acdb6df4 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -109,6 +109,9 @@ Forms
* Form widgets now render attributes with a value of ``True`` or ``False``
as HTML5 boolean attributes.
+* The new :meth:`~django.forms.Form.has_error()` method allows checking
+ if a specific error has happened.
+
Internationalization
^^^^^^^^^^^^^^^^^^^^