How to determine if a field has changed in a Django modelform

后端 未结 4 1362
甜味超标
甜味超标 2021-01-04 07:25

I was surprised that this was difficult to do. However I came up with this, which seems to work at least for my simple case. Can anyone recommend a better approach?

4条回答
  •  误落风尘
    2021-01-04 07:51

    Form contains a property changed_data which holds a list of all the fields whose values have changed.

    Try:

    'fieldname' in myforminstance.changed_data
    

提交回复
热议问题