[Django] #37122: JSONField has_changed doesn't reflect disabled correctly

18 views
Skip to first unread message

Django

unread,
May 28, 2026, 3:53:20 AM (3 days ago) May 28
to django-...@googlegroups.com
#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.

Django

unread,
May 28, 2026, 3:54:09 AM (3 days ago) May 28
to django-...@googlegroups.com
#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?
>
> ``` 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.

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.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:1>

Django

unread,
May 28, 2026, 3:55:23 AM (3 days ago) May 28
to django-...@googlegroups.com
#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?
>

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

unread,
May 28, 2026, 3:59:54 AM (3 days ago) May 28
to django-...@googlegroups.com
#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
-------------------------------+--------------------------------------
Comment (by alex):

Despite being mostly just informational there is a danger:

it can lead to serious work problems if people check the history of an
object and wrongly accuse employees to change values they aren't allowed
change or even hack their system.
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:3>

Django

unread,
May 28, 2026, 9:30:58 AM (2 days ago) May 28
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+------------------------------------
Reporter: alex | Owner: (none)
Type: Bug | Status: new
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+------------------------------------
Changes (by Simon Charette):

* component: Uncategorized => Forms
* has_patch: 1 => 0
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug

Comment:

There's effectively a bug here based on how `forms.Field.has_changed`
[https://github.com/django/django/blob/525e51f6ce7d77012b60a9bdbd098322f94bdd3f/django/forms/fields.py#L234-L239
is implemented].

Would you be willing to
[https://docs.djangoproject.com/en/6.0/internals/contributing/writing-code
/submitting-patches/ submit a patch]? Looks like a simple test could be
added
[https://github.com/django/django/blob/525e51f6ce7d77012b60a9bdbd098322f94bdd3f/tests/forms_tests/field_tests/test_jsonfield.py#L78
around here].
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:4>

Django

unread,
May 28, 2026, 11:13:15 AM (2 days ago) May 28
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+----------------------------------------
Reporter: alex | Owner: Vaibhav Pant
Type: Bug | Status: assigned
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+----------------------------------------
Changes (by Vaibhav Pant):

* owner: (none) => Vaibhav Pant
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:5>

Django

unread,
May 28, 2026, 10:52:16 PM (2 days ago) May 28
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+------------------------------------
Reporter: alex | Owner: (none)
Type: Bug | Status: new
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+------------------------------------
Changes (by Simon Charette):

* owner: Vaibhav Pant => (none)
* status: assigned => new

Comment:

Vaibhav please give the reporter the chance to answer before claiming the
ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:6>

Django

unread,
May 29, 2026, 5:11:51 PM (yesterday) May 29
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+------------------------------------
Reporter: alex | Owner: (none)
Type: Bug | Status: new
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+------------------------------------
Comment (by FrickWu):

Hi I would like to claim and work on this ticket, how do i go about doing
that? I tried following the Claim a ticket instructions but cant seem to
make it work.
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:7>

Django

unread,
May 29, 2026, 5:28:50 PM (yesterday) May 29
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+---------------------------------------
Reporter: alex | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+---------------------------------------
Changes (by Jacob Walls):

* owner: (none) => Jacob Walls
* status: new => assigned

Comment:

Sure thing. Use Modify Ticket button, click "assign to" radio button, set
your username, Submit changes.
--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:8>

Django

unread,
May 29, 2026, 5:28:57 PM (yesterday) May 29
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+------------------------------------
Reporter: alex | Owner: (none)
Type: Bug | Status: new
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+------------------------------------
Changes (by Jacob Walls):

* owner: Jacob Walls => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:9>

Django

unread,
8:23 AM (11 hours ago) 8:23 AM
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+------------------------------------
Reporter: alex | Owner: Frick Wu
Type: Bug | Status: assigned
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+------------------------------------
Changes (by Frick Wu):

* owner: (none) => Frick Wu
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:10>

Django

unread,
11:33 AM (8 hours ago) 11:33 AM
to django-...@googlegroups.com
#37122: JSONField has_changed doesn't reflect disabled correctly
------------------------+------------------------------------
Reporter: alex | Owner: Frick Wu
Type: Bug | Status: assigned
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------+------------------------------------
Changes (by Frick Wu):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:11>
Reply all
Reply to author
Forward
0 new messages