Closed hancush closed 4 years ago
I'm curious if it'd make sense to just fire the signal artificially in this case & skip the database write. From a quick glance it looks like that should be safe here, any thoughts on pros/cons?
@jamesturk That's a great point. The only con I can think of is that artificially firing post_save
would only support post-save signals that expect related objects, but I can't imagine you'd want to write a pre-save signal that expects data to already exist. Let me give it a shot.
@jamesturk Firing the signal directly seems to work as expected! Revised per your suggestion in 86006cf.
Description
This PR adds a line to save new objects after related objects are created. This allows use of Django's
post_save
signal to perform operations that depend on related objects.Take our use case as an example: We want to use some custom logic to determine a bill's last action date. This logic depends on two types of related objects, bill actions and event related entities. The change in this PR allows us to query related objects after
Event
andBill
save in order to determine the appropriate last action date.As ever, thanks for your work!