Skip to content

Commit e5ec680

Browse files
committed
document complex code related with _created management
1 parent e9a12ef commit e5ec680

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mongoengine/base/document.py

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ def __setattr__(self, name, value):
202202
and self__created
203203
and name == self._meta.get("id_field")
204204
):
205+
# When setting the ID field of an instance already instantiated and that was user-created (i.e not saved in db yet)
206+
# Typically this is when calling .save()
205207
super().__setattr__("_created", False)
206208

207209
super().__setattr__(name, value)

0 commit comments

Comments
 (0)