diff options
| author | Tim Graham <timograham@gmail.com> | 2014-04-05 18:14:53 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-04-05 18:17:13 -0400 |
| commit | 38679254bf2006c0b31bdb172802024836dac46c (patch) | |
| tree | 0be359b912ffe810c42843d058e3004cab55add7 /docs/ref/forms/api.txt | |
| parent | 5891fd3f89337fc190cf671575407233440d2736 (diff) | |
[1.7.x] Fixed #22216 -- Added Form.non_field_errors to form API doc.
Backport of d2f4553d705951ca8043d687f9493c559f494a0c from master
Diffstat (limited to 'docs/ref/forms/api.txt')
| -rw-r--r-- | docs/ref/forms/api.txt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 33fcf85511..4cf8e7d828 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -173,7 +173,8 @@ from a view. The ``field`` argument is the name of the field to which the errors should be added. If its value is ``None`` the error will be treated as -a non-field error as returned by ``Form.non_field_errors()``. +a non-field error as returned by :meth:`Form.non_field_errors() +<django.forms.Form.non_field_errors>`. The ``error`` argument can be a simple string, or preferably an instance of ``ValidationError``. See :ref:`raising-validation-error` for best practices @@ -182,6 +183,14 @@ when defining form errors. Note that ``Form.add_error()`` automatically removes the relevant field from ``cleaned_data``. +.. method:: Form.non_field_errors() + +This method returns the list of errors from :attr:`Form.errors +<django.forms.Form.errors>` that aren't associated with a particular field. +This includes ``ValidationError``\s that are raised in :meth:`Form.clean() +<django.forms.Form.clean>` and errors added using :meth:`Form.add_error(None, +"...") <django.forms.Form.add_error>`. + Behavior of unbound forms ~~~~~~~~~~~~~~~~~~~~~~~~~ |
