summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-06-24 14:23:24 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-06-24 14:23:24 +0000
commitb287f8a96fc30e74d85d5c04836a557611b033cc (patch)
treeea7394aa5f376d2f344f4bd7009eca52ac458ed3 /docs
parent34fbf191c14b7891a2ee74bca91cc5411b80ef6f (diff)
[1.0.X] Fixed #8861 -- Added note on the availability of ModelForm.instance. Thanks to Ramiro Morales for the patch.
Merge of r11097 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@11102 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/admin.txt6
-rw-r--r--docs/topics/forms/modelforms.txt19
2 files changed, 18 insertions, 7 deletions
diff --git a/docs/ref/contrib/admin.txt b/docs/ref/contrib/admin.txt
index 0d0d1d7ff7..bd6ca468ee 100644
--- a/docs/ref/contrib/admin.txt
+++ b/docs/ref/contrib/admin.txt
@@ -724,7 +724,7 @@ Adding custom validation to the admin
-------------------------------------
Adding custom validation of data in the admin is quite easy. The automatic admin
-interfaces reuses :mod:`django.forms`, and the ``ModelAdmin`` class gives you
+interface reuses :mod:`django.forms`, and the ``ModelAdmin`` class gives you
the ability define your own form::
class ArticleAdmin(admin.ModelAdmin):
@@ -744,7 +744,9 @@ any field::
It is important you use a ``ModelForm`` here otherwise things can break. See the
:ref:`forms <ref-forms-index>` documentation on :ref:`custom validation
-<ref-forms-validation>` for more information.
+<ref-forms-validation>` and, more specifically, the
+:ref:`model form validation notes <overriding-modelform-clean-method>` for more
+information.
.. _admin-inlines:
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 71d222070b..8872be665c 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -370,11 +370,20 @@ 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
----------------