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 BEFORE hooks #105

Open
maps82 opened this issue Apr 8, 2021 · 3 comments
Open

Support BEFORE hooks #105

maps82 opened this issue Apr 8, 2021 · 3 comments

Comments

@maps82
Copy link

maps82 commented Apr 8, 2021

Hello!

I noticed that only the AFTER_* hooks of django-lifecycle are implemented.

Wouldn't it be useful to also support the BEFORE_* hooks?

E.g. I have an attachment file model. If an object get's deleted I'd like to use a BEFORE_DELETE hook to also delete the related file in the filesystem. With OperationType.DELETE this is not possible as the object is removed and I can't access it's fields in the hook anymore.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2021

Thanks for reporting this issue.

@maps82
Copy link
Author

maps82 commented Apr 8, 2021

Sorry, I was wrong with my assumption. It's just the pk that is None. So no problem for my use case...

@jackton1
Copy link
Member

jackton1 commented Apr 8, 2021

Yeah correct, plan to support before and after decorators but for now only the pk would be set to None

https://github.com/tj-django/django-model-subscription#create-update-delete-operations

Using

@before_delete_subscription
def (..):
    ...


@after_delete_subscription
def (..):
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants