Document FieldDoesNotExist and meta.strict

This commit is contained in:
Axel Haustant 2015-04-13 18:07:48 +02:00
parent cd2d9517a0
commit 2bfb195ad6
3 changed files with 16 additions and 1 deletions

View File

@ -34,6 +34,9 @@ Documents
.. autoclass:: mongoengine.ValidationError
:members:
.. autoclass:: mongoengine.FieldDoesNotExist
Context Managers
================

View File

@ -135,6 +135,11 @@ class Document(BaseDocument):
doesn't contain a list) if allow_inheritance is True. This can be
disabled by either setting cls to False on the specific index or
by setting index_cls to False on the meta dictionary for the document.
By default, any extra attribute existing in stored data but not declared
in your model will raise a :class:`~mongoengine.FieldDoesNotExist` error.
This can be disabled by setting :attr:`strict` to ``False``
in the :attr:`meta` dictionnary.
"""
# The __metaclass__ attribute is removed by 2to3 when running with Python3

View File

@ -42,7 +42,14 @@ class NotUniqueError(OperationError):
class FieldDoesNotExist(Exception):
pass
"""Raised when trying to set a field
not declared in a :class:`~mongoengine.Document`
or an :class:`~mongoengine.EmbeddedDocument`.
To avoid this behavior on data loading,
you should the :attr:`strict` to ``False``
in the :attr:`meta` dictionnary.
"""
class ValidationError(AssertionError):