From 68c7764c63e3c7c5b854271cbdac29c748c55249 Mon Sep 17 00:00:00 2001 From: Luca Di Gaspero Date: Mon, 8 Oct 2018 17:06:08 +0200 Subject: [PATCH] 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). --- mongoengine/document.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mongoengine/document.py b/mongoengine/document.py index cdeed4c6..220047d8 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -368,6 +368,8 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): signals.pre_save_post_validation.send(self.__class__, document=self, 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): self.ensure_indexes()