Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13100 -- Clarified the model validation rules around full_clea…

…n(). Thanks to ptone for the draft text.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13160 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4a15dc450996b62596d74f8d98388c9e2f4a10c7 1 parent ed33513
Russell Keith-Magee authored May 09, 2010

Showing 1 changed file with 20 additions and 9 deletions. Show diff stats Hide diff stats

  1. 29  docs/ref/models/instances.txt
29  docs/ref/models/instances.txt
@@ -34,11 +34,22 @@ Validating objects
34 34
 
35 35
 .. versionadded:: 1.2
36 36
 
37  
-There are three steps in validating a model, and all three are called by a
38  
-model's ``full_clean()`` method. Most of the time, this method will be called
39  
-automatically by a ``ModelForm``. (See the :ref:`ModelForm documentation
40  
-<topics-forms-modelforms>` for more information.) You should only need to call
41  
-``full_clean()`` if you plan to handle validation errors yourself.
  37
+There are three steps involved in validating a model:
  38
+
  39
+    1. Validate the model fields
  40
+    2. Validate the model as a whole
  41
+    3. Validate the field uniqueness
  42
+
  43
+All three steps are performed when you call by a model's
  44
+``full_clean()`` method.
  45
+
  46
+When you use a ``ModelForm``, the call to ``is_valid()`` will perform
  47
+these validation steps for all the fields that are included on the
  48
+form. (See the :ref:`ModelForm documentation
  49
+<topics-forms-modelforms>` for more information.) You should only need
  50
+to call a model's ``full_clean()`` method if you plan to handle
  51
+validation errors yourself, or if you have excluded fields from the
  52
+ModelForm that require validation.
42 53
 
43 54
 .. method:: Model.full_clean(exclude=None)
44 55
 
@@ -51,10 +62,10 @@ that can be excluded from validation and cleaning. ``ModelForm`` uses this
51 62
 argument to exclude fields that aren't present on your form from being
52 63
 validated since any errors raised could not be corrected by the user.
53 64
 
54  
-Note that ``full_clean()`` will NOT be called automatically when you call
55  
-your model's ``save()`` method. You'll need to call it manually if you want
56  
-to run model validation outside of a ``ModelForm``. (This is for backwards
57  
-compatibility.)
  65
+Note that ``full_clean()`` will *not* be called automatically when you
  66
+call your model's ``save()`` method, nor as a result of ``ModelForm``
  67
+validation. You'll need to call it manually when you want to run model
  68
+validation outside of a ``ModelForm``.
58 69
 
59 70
 Example::
60 71
 

0 notes on commit 4a15dc4

Please sign in to comment.
Something went wrong with that request. Please try again.