#37122: JSONField has_changed doesn't reflect disabled correctly
----------------------+-----------------------------------------
Reporter: alex | Type: Uncategorized
Status: new | Component: Uncategorized
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------+-----------------------------------------
Problem:
A disabled JSONField still reports changes via has_changed.
Why?
``` python
def has_changed(self, initial, data):
# here we miss the check for disabled
if super().has_changed(initial, data):
return True
...
```
As we see, has_changed from the base is called and if successful, True is
returned. But we have no additional check for disabled.
Fix:
``` python
def has_changed(self, initial, data):
if self.disabled:
return False
if super().has_changed(initial, data):
return True
...
```
This corrupts the changed fields in the history of admin.
--
Ticket URL: <
https://code.djangoproject.com/ticket/37122>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.