django-lifecycle icon indicating copy to clipboard operation
django-lifecycle copied to clipboard

id/pk field is None AFTER_DELETE

Open swehba opened this issue 2 years ago • 1 comments

It's not a big deal to the workflow I am trying to build, but I was surprised to see that a model's id/pk field is set to None by the time the handler for AFTER_DELETE is called. All other fields retain their values. Is this expected behavior?

swehba avatar Jun 14 '22 21:06 swehba

Yes, this is the expected behaviour. Keep in mind that this gets executed after deletion. If you need the pk probably you should be using BEFORE_DELETE.

Similarly, on BEFORE_CREATE the pk is not set.

EnriqueSoria avatar Jun 30 '22 15:06 EnriqueSoria