I have been testing mongoengine. I want to update some fields of a document and know which ones have been changed using the pre_save method
I have the following document
from mongoengine import Document, StringField, EmailField, IntField, signals
import bcrypt
class Users(Document):
name = StringField(required=True)
mail = EmailField(required=True, unique=True)
age = IntField(required=True, default=0)
password = StringField(min_length=7, required=True)
@classmethod
def pre_save(cls, sender, document, **kwargs):
# if password.isChanged(): <-- How can I get this?
# document.password = bcrypt(document.password, "randonSalt")
signals.pre_save.connect(Users.pre_save, sender=Users)
I tried accessing document._changed_fields
, but it shows up as an empty array
Thank you all