Author: russellm
Date: 2009-06-24 09:04:18 -0500 (Wed, 24 Jun 2009)
New Revision: 11097

Modified:
   django/trunk/docs/ref/contrib/admin/index.txt
   django/trunk/docs/topics/forms/modelforms.txt
Log:
Fixed #8861 -- Added note on the availability of ModelForm.instance. Thanks to 
Ramiro Morales for the patch.

Modified: django/trunk/docs/ref/contrib/admin/index.txt
===================================================================
--- django/trunk/docs/ref/contrib/admin/index.txt       2009-06-24 14:03:10 UTC 
(rev 11096)
+++ django/trunk/docs/ref/contrib/admin/index.txt       2009-06-24 14:04:18 UTC 
(rev 11097)
@@ -870,7 +870,7 @@
 -------------------------------------
 
 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):
@@ -890,7 +890,9 @@
 
 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:
 

Modified: django/trunk/docs/topics/forms/modelforms.txt
===================================================================
--- django/trunk/docs/topics/forms/modelforms.txt       2009-06-24 14:03:10 UTC 
(rev 11096)
+++ django/trunk/docs/topics/forms/modelforms.txt       2009-06-24 14:04:18 UTC 
(rev 11097)
@@ -397,17 +397,27 @@
     ...         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
 ----------------
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to