Return True if data differs from initial.
(self, initial, data)
| 232 | return {} |
| 233 | |
| 234 | def has_changed(self, initial, data): |
| 235 | """Return True if data differs from initial.""" |
| 236 | # Always return False if the field is disabled since self.bound_data |
| 237 | # always uses the initial value in this case. |
| 238 | if self.disabled: |
| 239 | return False |
| 240 | try: |
| 241 | data = self.to_python(data) |
| 242 | if hasattr(self, "_coerce"): |
| 243 | return self._coerce(data) != self._coerce(initial) |
| 244 | except ValidationError: |
| 245 | return True |
| 246 | # For purposes of seeing whether something has changed, None is |
| 247 | # the same as an empty string, if the data or initial value we get |
| 248 | # is None, replace it with ''. |
| 249 | initial_value = initial if initial is not None else "" |
| 250 | data_value = data if data is not None else "" |
| 251 | return initial_value != data_value |
| 252 | |
| 253 | def get_bound_field(self, form, field_name): |
| 254 | """ |