diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-09-01 19:08:08 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-09-01 19:08:08 +0000 |
| commit | ea05e61b2b8c0c9e5e10faa3f738b09b5f59adf1 (patch) | |
| tree | 2d6d06282a7f9bd1203a1e7b002e977b1903cc0a /docs | |
| parent | 5f31e9bd33269484689d5d5f078a979f71edcade (diff) | |
Fixed #8209: `ModelForm`s now validate unique constraints. Alex Gaynor did much of this work, and Brian Rosner helped as well.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index d161b3f7f5..fe1e053d50 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -338,6 +338,16 @@ parameter when declaring the form field:: ... class Meta: ... model = Article +Overriding the clean() method +----------------------------- + +You can overide the ``clean()`` method on a model form to provide additional +validation in the same way you can on a normal form. However, by default the +``clean()`` method validates the uniqueness of fields that are marked as unique +on the model, and those marked as unque_together, if you would like to overide +the ``clean()`` method and maintain the default validation you must call the +parent class's ``clean()`` method. + Form inheritance ---------------- @@ -500,4 +510,4 @@ books of a specific author. Here is how you could accomplish this:: >>> from django.forms.models import inlineformset_factory >>> BookFormSet = inlineformset_factory(Author, Book) >>> author = Author.objects.get(name=u'Orson Scott Card') - >>> formset = BookFormSet(instance=author)
\ No newline at end of file + >>> formset = BookFormSet(instance=author) |
