Opened 87 minutes ago
Last modified 79 minutes ago
#37122 new Uncategorized
JSONField has_changed doesn't reflect disabled correctly — at Version 2
| Reported by: | alex | Owned by: | |
|---|---|---|---|
| Component: | Uncategorized | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Problem:
A disabled JSONField still reports changes via has_changed.
Why?
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:
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 (disabled JSONFields are always shown as changed).
Change History (2)
comment:1 by , 86 minutes ago
| Description: | modified (diff) |
|---|
comment:2 by , 85 minutes ago
| Description: | modified (diff) |
|---|
Note:
See TracTickets
for help on using tickets.