Ticket #21894: 21894.diff

File 21894.diff, 1.1 KB (added by Tim Graham, 9 years ago)
  • docs/ref/forms/validation.txt

    diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt
    index 5f6db43..5f66e3b 100644
    a b In this code, if the validation error is raised, the form will display an  
    372372error message at the top of the form (normally) describing the problem.
    373373
    374374Note that the call to ``super(ContactForm, self).clean()`` in the example code
    375 ensures that any validation logic in parent classes is maintained.
     375ensures that any validation logic in parent classes is maintained. If your form
     376inherits another that doesn't return a ``cleaned_data`` dictionary in its
     377``clean()`` method, then don't assign ``cleaned_data`` to the result of the
     378``super()`` call and use ``self.cleaned_data`` instead::
     379
     380    def clean(self):
     381        super(ContactForm, self).clean()
     382        cc_myself = self.cleaned_data.get("cc_myself")
     383        ...
    376384
    377385The second approach might involve assigning the error message to one of the
    378386fields. In this case, let's assign an error message to both the "subject" and
Back to Top