Django: Before a model is updated, I'd like to “look at” its previous attributes

后端 未结 5 712
星月不相逢
星月不相逢 2021-02-13 16:36

When an update/create is performed on a Django model (.save()) I would like to be able to \"step in\" and compare some particular attributes to what they were set t

5条回答
  •  情话喂你
    2021-02-13 17:07

    You can ask for the currently stored values in the database before you save. I have done this to log only changed values, but it causes another database query each time you save.

提交回复
热议问题