summaryrefslogtreecommitdiff
path: root/docs/ref/forms
diff options
context:
space:
mode:
authorFrançois Freitag <mail@franek.fr>2020-02-12 14:48:49 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-04-28 10:49:00 +0200
commit9ef4a18dbe71f538a9ef8c39111ae2f0b62eb90b (patch)
tree0016b13a357af2f642483bdd168d6f83190f33bb /docs/ref/forms
parent2788de95e375cccd03a3dfd161fc92b7d6df6024 (diff)
Changed django.forms.ValidationError imports to django.core.exceptions.ValidationError.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'docs/ref/forms')
-rw-r--r--docs/ref/forms/fields.txt5
-rw-r--r--docs/ref/forms/validation.txt6
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."
)