Skip to content

Commit

Permalink
document complex code related with _created management
Browse files Browse the repository at this point in the history
  • Loading branch information
bagerard committed Aug 15, 2024
1 parent e9a12ef commit e5ec680
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mongoengine/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def __setattr__(self, name, value):
and self__created
and name == self._meta.get("id_field")
):
# When setting the ID field of an instance already instantiated and that was user-created (i.e not saved in db yet)
# Typically this is when calling .save()
super().__setattr__("_created", False)

super().__setattr__(name, value)
Expand Down

0 comments on commit e5ec680

Please sign in to comment.