Ticket #22216: 22216.diff

File 22216.diff, 3.6 KB (added by Tim Graham, 11 years ago)
  • docs/ref/forms/api.txt

    diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
    index f2136b2..8a53037 100644
    a b from a view.  
    173173
    174174The ``field`` argument is the name of the field to which the errors
    175175should be added. If its value is ``None`` the error will be treated as
    176 a non-field error as returned by ``Form.non_field_errors()``.
     176a non-field error as returned by :meth:`Form.non_field_errors()
     177<django.forms.Form.non_field_errors>`.
    177178
    178179The ``error`` argument can be a simple string, or preferably an instance of
    179180``ValidationError``. See :ref:`raising-validation-error` for best practices
    if the field contains any errors at all.  
    193194To check for non-field errors use
    194195:data:`~django.core.exceptions.NON_FIELD_ERRORS` as the ``field`` parameter.
    195196
     197.. method:: Form.non_field_errors()
     198
     199This method returns the list of errors from :attr:`Form.errors
     200<django.forms.Form.errors>`  that aren't associated with a particular field.
     201This includes ``ValidationError``\s that are raised in :meth:`Form.clean()
     202<django.forms.Form.clean>` and errors added using :meth:`Form.add_error(None,
     203"...") <django.forms.Form.add_error>`.
     204
    196205Behavior of unbound forms
    197206~~~~~~~~~~~~~~~~~~~~~~~~~
    198207
  • docs/ref/forms/validation.txt

    diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt
    index 13c1e5a..63fc6f2 100644
    a b overridden:  
    8585  Note that any errors raised by your ``Form.clean()`` override will not
    8686  be associated with any field in particular. They go into a special
    8787  "field" (called ``__all__``), which you can access via the
    88   ``non_field_errors()`` method if you need to. If you want to attach
    89   errors to a specific field in the form, you need to call
     88  :meth:`~django.forms.Form.non_field_errors` method if you need to. If you
     89  want to attach errors to a specific field in the form, you need to call
    9090  :meth:`~django.forms.Form.add_error()`.
    9191
    9292  Also note that there are special considerations when overriding
    form's ``clean()`` method, in which case you can use  
    329329:meth:`~django.forms.Form.add_error()`. Note that this won't always be
    330330appropriate and the more typical situation is to raise a ``ValidationError``
    331331from , which is turned into a form-wide error that is available through the
    332 ``Form.non_field_errors()`` method.
     332:meth:`Form.non_field_errors() <django.forms.Form.non_field_errors>` method.
    333333
    334334Cleaning and validating fields that depend on each other
    335335~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • docs/topics/testing/tools.txt

    diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
    index f56cbee..30eec42 100644
    a b your test suite.  
    12691269
    12701270    ``field`` is the name of the field on the form to check. If ``field``
    12711271    has a value of ``None``, non-field errors (errors you can access via
    1272     ``form.non_field_errors()``) will be checked.
     1272    :meth:`form.non_field_errors() <django.forms.Form.non_field_errors>`) will
     1273    be checked.
    12731274
    12741275    ``errors`` is an error string, or a list of error strings, that are
    12751276    expected as a result of form validation.
    your test suite.  
    12881289
    12891290    ``field`` is the name of the field on the form to check. If ``field``
    12901291    has a value of ``None``, non-field errors (errors you can access via
    1291     ``form.non_field_errors()``) will be checked.
     1292    :meth:`form.non_field_errors() <django.forms.Form.non_field_errors>`) will
     1293    be checked.
    12921294
    12931295    ``errors`` is an error string, or a list of error strings, that are
    12941296    expected as a result of form validation.
Back to Top