added a 'validate' option to Document.save() +docs +tests

This commit is contained in:
Nicolas Perriault
2010-09-11 17:45:57 +02:00
parent 196606438c
commit 449f5a00dc
3 changed files with 28 additions and 2 deletions

View File

@@ -214,6 +214,20 @@ either a single field name, or a list or tuple of field names::
first_name = StringField()
last_name = StringField(unique_with='first_name')
Skipping Document validation on save
------------------------------------
You can also skip the whole document validation process by setting
``validate=False`` when caling the :meth:`~mongoengine.document.Document.save`
method::
class Recipient(Document):
name = StringField()
email = EmailField()
recipient = Recipient(name='admin', email='root@localhost')
recipient.save() # will raise a ValidationError while
recipient.save(validate=False) # won't
Document collections
====================
Document classes that inherit **directly** from :class:`~mongoengine.Document`