Opened 87 minutes ago

Last modified 79 minutes ago

#37122 new Uncategorized

JSONField has_changed doesn't reflect disabled correctly — at Version 1

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 alex)

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.

Change History (1)

comment:1 by alex, 86 minutes ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top