In Django 1.4, do Form.has_changed() and Form.changed_data, which are undocumented, work as expected?

前端 未结 3 669
天命终不由人
天命终不由人 2020-12-08 16:01

From the source code, you can see that Django 1.4\'s Form class has a has_changed() method and changed_data property which seem rather

3条回答
  •  甜味超标
    2020-12-08 16:46

    You can rely on those methods on two conditions:

    1. You pass the initial data dict to the form constructor during post requests too.
    2. You don't use fields with show_hidden_initial=True. (The issue with such fields is that a user can submit the initial value used for comparison too and as such it wouldn't be trustworthy.)

提交回复
热议问题