Opened 6 years ago
Closed 6 years ago
#30662 closed New feature (wontfix)
Add a signal at the end of Model.refresh_from_db().
| Reported by: | Craig de Stigter | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I have an app that allows callers to subscribe to a post_save_changed signal on particular fields, when those fields have changed.
It works by recording values in the post_init signal, then checking their values in the post_save signal, and then triggering its own post_save_changed signal if the values are different.
The problem is that currently there's no way this can detect someone calling Model.refresh_from_db(). If I could detect that, I would overwrite the stored values from post_init with some new values. Otherwise my app may detect 'changes' which have actually already been applied to the database.
A post_refresh_from_db signal seems conspicuously absent. Or perhaps post_init should be called again when refresh_from_db is called? That would also solve my problem.
Change History (2)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Summary: | Add a signal at the end of Model.refresh_from_db() → Add a signal at the end of Model.refresh_from_db(). |
| Version: | 2.2 → master |
Thanks for this ticket, however I think it's quite niche and even with this signal you will have few missing scenarios e.g. using QuerySet.update() (see #21461).
Needs discussion on the django-developers mailing list in order to be accepted.
Ticket on my app for this: https://github.com/craigds/django-fieldsignals/issues/17