You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to create a mixin to add "created" and "updated" fields, much like the docs show except these will be required fields. So I've added pre_insert and pre_update methods to the mixin to be sure those fields get set before storing the doc. The fields are getting added to the model fine, but the hooks are not getting called and I'm getting errors due to those required fields not being set.
@instance.register
class TimeMixin(MixinDocument):
created = DateTimeField(required=True)
updated = DateTimeField(required=True)
def pre_insert(self):
self.created = datetime.datetime.utcnow()
self.updated = datetime.datetime.utcnow()
def pre_update(self):
self.updated = datetime.datetime.utcnow()
@instance.register
class MyDoc(Document, TimeMixin):
...
My "MyDoc" class does not have any hooks defined on it.
Is this a bug or am I missing something obvious? I'm using umongo 3.0.0.
The text was updated successfully, but these errors were encountered:
I'm attempting to create a mixin to add "created" and "updated" fields, much like the docs show except these will be required fields. So I've added pre_insert and pre_update methods to the mixin to be sure those fields get set before storing the doc. The fields are getting added to the model fine, but the hooks are not getting called and I'm getting errors due to those required fields not being set.
My "MyDoc" class does not have any hooks defined on it.
Is this a bug or am I missing something obvious? I'm using umongo 3.0.0.
The text was updated successfully, but these errors were encountered: