#37122: JSONField has_changed doesn't reflect disabled correctly
-------------------------------+--------------------------------------
Reporter: alex | Owner: (none)
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by alex:
Old description:
> 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.
New description:
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).
--
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019e6d949eae-cc7d7a71-46ba-4881-ade2-ad1230a90467-000000%40eu-central-1.amazonses.com.