diff options
| author | François Freitag <mail@franek.fr> | 2020-02-12 14:48:49 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-28 10:49:00 +0200 |
| commit | 9ef4a18dbe71f538a9ef8c39111ae2f0b62eb90b (patch) | |
| tree | 0016b13a357af2f642483bdd168d6f83190f33bb /docs/topics/forms | |
| parent | 2788de95e375cccd03a3dfd161fc92b7d6df6024 (diff) | |
Changed django.forms.ValidationError imports to django.core.exceptions.ValidationError.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/formsets.txt | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index d6aafaa8b5..2f3e4403f6 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -220,7 +220,7 @@ this management data, an exception will be raised:: >>> formset.is_valid() Traceback (most recent call last): ... - django.forms.utils.ValidationError: ['ManagementForm data is missing or has been tampered with'] + django.core.exceptions.ValidationError: ['ManagementForm data is missing or has been tampered with'] It is used to keep track of how many form instances are being displayed. If you are adding new forms via JavaScript, you should increment the count fields @@ -261,6 +261,7 @@ Custom formset validation A formset has a ``clean`` method similar to the one on a ``Form`` class. This is where you define your own validation that works at the formset level:: + >>> from django.core.exceptions import ValidationError >>> from django.forms import BaseFormSet >>> from django.forms import formset_factory >>> from myapp.forms import ArticleForm @@ -277,7 +278,7 @@ is where you define your own validation that works at the formset level:: ... continue ... title = form.cleaned_data.get('title') ... if title in titles: - ... raise forms.ValidationError("Articles in a set must have distinct titles.") + ... raise ValidationError("Articles in a set must have distinct titles.") ... titles.append(title) >>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet) |
