#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.

-- 
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/0107019e6d92c008-9021e0ab-ca18-49ec-9704-437205ae07c3-000000%40eu-central-1.amazonses.com.

Reply via email to