From ea05e61b2b8c0c9e5e10faa3f738b09b5f59adf1 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 1 Sep 2008 19:08:08 +0000 Subject: 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 --- docs/topics/forms/modelforms.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'docs/topics/forms/modelforms.txt') 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) -- cgit v1.3