Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pre/post-save and pre/post-update #63

Closed
soderluk opened this issue Dec 3, 2020 · 2 comments
Closed

Support pre/post-save and pre/post-update #63

soderluk opened this issue Dec 3, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@soderluk
Copy link

soderluk commented Dec 3, 2020

Any thoughts on supporting some kind of pre-save, and pre-update (and why not pre/post-delete) functionality? Either as functions to override, or events?

As a use case, I've got created_at and updated_at datetimes for my models. Setting the default value works, but e.g. when updating a model, I'd like to automatically set the updated_at to current datetime. Now I have to manually add the timestamp to the model for it to update.

Of course I can make a base class of my own, and override the save and update functions, but it seems a bit overkill. Also a lot of the libraries out there has some kind of functionality for these kind of situations.

Thoughts?

@collerek collerek added the enhancement New feature or request label Dec 3, 2020
@collerek
Copy link
Owner

collerek commented Dec 3, 2020

Yep, sounds like a good idea.

Probably something like a decorator registering event/signal for a given method.

Alternative or maybe additional functionality might be adding some kind of parameters like 'on_update' and 'on_delete'.

@collerek
Copy link
Owner

collerek commented Dec 6, 2020

Should be closed in #66

@collerek collerek closed this as completed Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants