summaryrefslogtreecommitdiff
path: root/docs/topics/forms
diff options
context:
space:
mode:
authorChris Cahoon <chris.cahoon@gmail.com>2009-06-25 15:42:51 +0000
committerChris Cahoon <chris.cahoon@gmail.com>2009-06-25 15:42:51 +0000
commiteac54911f5df8a31377fecd37b2bf34f0afef169 (patch)
treee5028a9673b5cbc337f380a6c808816236932f7b /docs/topics/forms
parent7acae8f4d8a8f191d46fbb16e8cb15f46644b2ca (diff)
[soc2009/http-wsgi-improvements] Merged up to 11103 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/http-wsgi-improvements@11109 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/forms')
-rw-r--r--docs/topics/forms/modelforms.txt22
1 files changed, 16 insertions, 6 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 690ca7f391..add581268b 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -397,16 +397,26 @@ to be rendered first, we could specify the following ``ModelForm``::
... model = Book
... fields = ['title', 'author']
+.. _overriding-modelform-clean-method:
Overriding the clean() method
-----------------------------
You can override 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``, ``unique_together`` or ``unique_for_date|month|year`` on the model.
-Therefore, if you would like to override the ``clean()`` method and maintain the
-default validation, you must call the parent class's ``clean()`` method.
+validation in the same way you can on a normal form.
+
+In this regard, model forms have two specific characteristics when compared to
+forms:
+
+By default the ``clean()`` method validates the uniqueness of fields that are
+marked as ``unique``, ``unique_together`` or ``unique_for_date|month|year`` on
+the model. Therefore, if you would like to override the ``clean()`` method and
+maintain the default validation, you must call the parent class's ``clean()``
+method.
+
+Also, a model form instance bound to a model object will contain a
+``self.instance`` attribute that gives model form methods access to that
+specific model instance.
Form inheritance
----------------
@@ -611,7 +621,7 @@ Just like with ``ModelForms``, by default the ``clean()`` method of a
the unique constraints on your model (either ``unique``, ``unique_together`` or
``unique_for_date|month|year``). If you want to overide the ``clean()`` method
on a ``model_formset`` and maintain this validation, you must call the parent
-classes ``clean`` method::
+class's ``clean`` method::
class MyModelFormSet(BaseModelFormSet):
def clean(self):