Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 jkocherhans authored
Showing with 23 additions and 0 deletions.
  1. +10 −0 docs/releases/1.2.txt
  2. +13 −0 docs/topics/forms/modelforms.txt
10 docs/releases/1.2.txt
View
@@ -299,6 +299,16 @@ For those following trunk, this change also applies to other decorators
introduced since 1.1, including ``csrf_protect``, ``cache_control`` and anything
created using ``decorator_from_middleware``.
+``ModelForm.is_valid()`` and ``ModelForm.errors``
+-------------------------------------------------
+
+Much of the validation work for ModelForms has been moved down to the model
+level. As a result, the first time you call ``ModelForm.is_valid()``, access
+``ModelForm.errors`` or otherwise trigger form validation, your model will be
+cleaned in-place. This conversion used to happen when the model was saved. If
+you need an unmodified instance of your model, you should pass a copy to the
+``ModelForm`` constructor.
+
.. _deprecated-features-1.2:
13 docs/topics/forms/modelforms.txt
View
@@ -196,6 +196,19 @@ we'll discuss in a moment.)::
name = forms.CharField(max_length=100)
authors = forms.ModelMultipleChoiceField(queryset=Author.objects.all())
+The ``is_valid()`` method and ``errors``
+----------------------------------------
+
+.. versionchanged:: 1.2
+
+The first time you call ``is_valid()`` or access the ``errors`` attribute of a
+``ModelForm`` has always triggered form validation, but as of Django 1.2, it
+will also trigger :ref:`model validation <validating-objects>`. This has the
+side-effect of cleaning the model you pass to the ``ModelForm`` constructor.
+For instance, calling ``is_valid()`` on your form will convert any date fields
+on your model to actual date objects.
+
+
The ``save()`` method
---------------------
Please sign in to comment.
Something went wrong with that request. Please try again.