diff options
Diffstat (limited to 'docs/ref/forms')
| -rw-r--r-- | docs/ref/forms/fields.txt | 5 | ||||
| -rw-r--r-- | docs/ref/forms/validation.txt | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 92c1af63d7..3d228e88ad 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -18,8 +18,9 @@ other hooks. Although the primary way you'll use ``Field`` classes is in ``Form`` classes, you can also instantiate them and use them directly to get a better idea of how they work. Each ``Field`` instance has a ``clean()`` method, which takes -a single argument and either raises a ``django.forms.ValidationError`` -exception or returns the clean value:: +a single argument and either raises a +``django.core.exceptions.ValidationError`` exception or returns the clean +value:: >>> from django import forms >>> f = forms.EmailField() diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt index d12232afc7..c3fa968bdb 100644 --- a/docs/ref/forms/validation.txt +++ b/docs/ref/forms/validation.txt @@ -305,6 +305,7 @@ don't want to put it into the general ``MultiEmailField`` class. Instead, we write a cleaning method that operates on the ``recipients`` field, like so:: from django import forms + from django.core.exceptions import ValidationError class ContactForm(forms.Form): # Everything as before. @@ -313,7 +314,7 @@ write a cleaning method that operates on the ``recipients`` field, like so:: def clean_recipients(self): data = self.cleaned_data['recipients'] if "fred@example.com" not in data: - raise forms.ValidationError("You have forgotten about Fred!") + raise ValidationError("You have forgotten about Fred!") # Always return a value to use as the new cleaned data, even if # this method didn't change it. @@ -346,6 +347,7 @@ an error, you can raise a ``ValidationError`` from the ``clean()`` method. For example:: from django import forms + from django.core.exceptions import ValidationError class ContactForm(forms.Form): # Everything as before. @@ -359,7 +361,7 @@ example:: if cc_myself and subject: # Only do something if both fields are valid so far. if "help" not in subject: - raise forms.ValidationError( + raise ValidationError( "Did not send for 'help' in the subject despite " "CC'ing yourself." ) |
