Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12896. Documented the new side-effects of ModelForm validation.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12693 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fa6c967438e8c22b63b3cc0ef71815525f15856a 1 parent 90616a7
Joseph Kocherhans authored March 06, 2010
10  docs/releases/1.2.txt
@@ -299,6 +299,16 @@ For those following trunk, this change also applies to other decorators
299 299
 introduced since 1.1, including ``csrf_protect``, ``cache_control`` and anything
300 300
 created using ``decorator_from_middleware``.
301 301
 
  302
+``ModelForm.is_valid()`` and ``ModelForm.errors``
  303
+-------------------------------------------------
  304
+
  305
+Much of the validation work for ModelForms has been moved down to the model
  306
+level. As a result, the first time you call ``ModelForm.is_valid()``, access
  307
+``ModelForm.errors`` or otherwise trigger form validation, your model will be
  308
+cleaned in-place. This conversion used to happen when the model was saved. If
  309
+you need an unmodified instance of your model, you should pass a copy to the
  310
+``ModelForm`` constructor.
  311
+
302 312
 
303 313
 .. _deprecated-features-1.2:
304 314
 
13  docs/topics/forms/modelforms.txt
@@ -196,6 +196,19 @@ we'll discuss in a moment.)::
196 196
         name = forms.CharField(max_length=100)
197 197
         authors = forms.ModelMultipleChoiceField(queryset=Author.objects.all())
198 198
 
  199
+The ``is_valid()`` method and ``errors``
  200
+----------------------------------------
  201
+
  202
+.. versionchanged:: 1.2
  203
+
  204
+The first time you call ``is_valid()`` or access the ``errors`` attribute of a
  205
+``ModelForm`` has always triggered form validation, but as of Django 1.2, it
  206
+will also trigger :ref:`model validation <validating-objects>`. This has the
  207
+side-effect of cleaning the model you pass to the ``ModelForm`` constructor.
  208
+For instance, calling ``is_valid()`` on your form will convert any date fields
  209
+on your model to actual date objects.
  210
+
  211
+
199 212
 The ``save()`` method
200 213
 ---------------------
201 214
 

0 notes on commit fa6c967

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