Small fix to ensure to use the right document after pre_save_post_validation hook, which might modify the document itself (e.g., for adding a etag).

This commit is contained in:
Luca Di Gaspero 2018-10-08 17:06:08 +02:00
parent 55fc04752a
commit 68c7764c63

View File

@ -368,6 +368,8 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)):
signals.pre_save_post_validation.send(self.__class__, document=self, signals.pre_save_post_validation.send(self.__class__, document=self,
created=created, **signal_kwargs) created=created, **signal_kwargs)
# it might be refreshed by the pre_save_post_validation hook, e.g., for etag generation
doc = self.to_mongo()
if self._meta.get('auto_create_index', True): if self._meta.get('auto_create_index', True):
self.ensure_indexes() self.ensure_indexes()