Skip to content

Instantly share code, notes, and snippets.

@loic
Last active December 19, 2015 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loic/6009660 to your computer and use it in GitHub Desktop.
Save loic/6009660 to your computer and use it in GitHub Desktop.
The first time you call ``is_valid()`` or access the ``errors`` attribute of a
``ModelForm`` triggers :ref:`form validation <form-and-field-validation>` as
-well as :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. If form validation fails, only some of the updates
-may be applied. For this reason, you'll probably want to avoid reusing the
-model instance passed to the form, especially if validation fails.
+well as :ref:`model validation <validating-objects>`.
+
+.. warning::
+
+ The cleaning process modifies the model instance passed to the
+ ``ModelForm`` constructor in various ways. For instance any date fields on
+ the model is converted into actual date objects. Failed validation may
+ leave the underlying model instance in an inconsistent state and for this
+ reason it's not recommended to reuse it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment