I'm using Django 2.2 and I have a model with auto_now
modification_datetime
field and I need to update it during/after a bulk_update
execution only for the affected registries that were really updated.
Is it possible to update auto_now
datetime model field only on the affected records by bulk_update
execution?
No as
bulk_update()
does not callsave()
method nor it firespre_save
andpost_save
signals on instance ( generally produces only single update query). Also generally there is no recollection of the instances that are actually updated in Djangofurthermore as documented
auto_now
does not trigger on update()/bulk_update() as it is triggered bysave()
You could check which instances have update manually and update their timestamp or do some kind of database trigger