- All document fields are lazily evaluated, resulting in much faster object initialization time.
_datais removed due to lazy evaluation.to_dict()can be used to convert a document to a dictionary, and_internal_datacontains previously evaluated data.- Field methods
to_python,from_python,to_mongo,value_for_instance:to_pythonis called when converting from a MongoDB type to a document Python type only.from_pythonis called when converting an assignment in Python to the document Python type.to_mongois called when converting from a document Python type to a MongoDB type.value_for_instanceis called just before returning a value in Python allowing for instance-specific transformations.
pre_init,post_init,pre_save_post_validationsignals are removed to ensure fast object initialization.DecimalFieldis removed since there is no corresponding MongoDB typeLongFieldis removed since it is equivalent withIntField- Adding
SafeReferenceFieldwhich returns None if the reference does not exist. - Adding
SafeReferenceListFieldwhich doesn't return references that don't exist. - Accessing a
ListField(ReferenceField)doesn't automatically dereference all objects since they are lazily evaluated. ASafeReferenceListFieldmay be used instead. - Accessing a related object's id doesn't fetch the object from the database, e.g.
book.author.idwhere author is aReferenceFieldwill not make a database lookup except when using aSafeReferenceField. When inheritance is allowed, a proxy object will be returned, otherwise a lazy object from the referenced document class will be returned. - The primary key is only stored as
_idin the database and is referenced in Python aspkor as the name of the primary key field. - Saves are not cascaded by default.
Document.save()supportsfull=Truekeyword argument to force saving all model fields._get_changed_fields()/_changed_fieldsreturns a set of field names (not db field names)- Simplified
EmailFieldemail regex to be more compatible - Assigning invalid types (e.g. an invalid string to
IntField) raises immediately aValueError order_by()without an argument resets the ordering (no ordering will be applied)
- Dynamic documents /
DynamicField, dynamic addition/deletion of fields - Field display name methods
SequenceField- Pickling documents
FileField- All Geo fields
no_dereference()- using
SafeReferenceListFieldwithGenericReferenceField max_depthargument fordoc.reload()