[Django] #26949: Disabled forms.JSONField crashes with TypeError

64 views
Skip to first unread message

Django

unread,
Jul 25, 2016, 2:20:53 PM7/25/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
--------------------------------------------+---------------------
Reporter: timgraham | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+---------------------
The fix for #25532 is partially reverted to fix the regression in #26917
but this means the following test fails with `TypeError: the JSON object
must be str, not 'list'.`:

{{{ #!python
def test_formfield_disabled(self):
class JsonForm(Form):
name = CharField()
jfield = forms.JSONField(disabled=True)

form = JsonForm({'name': 'xyz', 'jfield': '["bar"]'},
initial={'jfield': ['foo']})
self.assertIn('[&quot;foo&quot;]</textarea>', form.as_p())
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26949>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 26, 2016, 4:51:53 AM7/26/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by alexyer):

* owner: => alexyer
* status: new => assigned


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

Django

unread,
Jul 26, 2016, 7:30:13 AM7/26/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by alexyer):

* Attachment "0001-Fix-disabled-forms.JSONField-crash-with-
TypeError.patch" added.

As I see the problem with previous fix was because assumption that initial
values are already cleaned is wrong. I added these lines to omit
`json.loads()` for disable field. But I think that's the obvious fix,
means there are downsides here if it's not been done before, so I'm not
sure about it. Could you, please, advice what could be wrong with this
approach? Thanks!

Django

unread,
Jul 26, 2016, 8:20:59 AM7/26/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1


Comment:

Looks okay to me. I added that fix to my
[https://github.com/django/django/pull/6972 PR] for the other ticket.
Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/26949#comment:2>

Django

unread,
Jul 26, 2016, 8:24:39 AM7/26/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by alexyer):

Should I create PR for the 1.9 branch or it's not required?

--
Ticket URL: <https://code.djangoproject.com/ticket/26949#comment:3>

Django

unread,
Jul 26, 2016, 9:17:09 AM7/26/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by timgraham):

Not needed since the committer will backport any commits as needed. I
think I'll just backport to 1.10 only since 1.9.x will be in security fix
only mode after the 1.10 release next week.

--
Ticket URL: <https://code.djangoproject.com/ticket/26949#comment:4>

Django

unread,
Jul 26, 2016, 9:18:35 AM7/26/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by alexyer):

Ok. Thanks for the fast and clear response!

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

Django

unread,
Jul 27, 2016, 8:36:24 AM7/27/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"a5f85d891b51d7ceb4f9e422e3e4f5c741062288" a5f85d89]:
{{{
#!CommitTicketReference repository=""
revision="a5f85d891b51d7ceb4f9e422e3e4f5c741062288"
Fixed #26917 -- Fixed crash in disabled ModelChoiceFields.

Partially reverted refs #25532 to fix a regression in Django 1.10.
This reintroduces a crash for disabled forms.JSONField (refs #26949),
however, that issue is also present on Django 1.9.

Thanks Ryan Schave for the test.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26949#comment:6>

Django

unread,
Jul 27, 2016, 8:36:26 AM7/27/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"68de48c96328e13d5dbdb1f3006e4a1ca74f3c34" 68de48c]:
{{{
#!CommitTicketReference repository=""
revision="68de48c96328e13d5dbdb1f3006e4a1ca74f3c34"
Fixed #26949 -- Fixed crash of disabled forms.JSONField.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26949#comment:7>

Django

unread,
Jul 27, 2016, 8:43:15 AM7/27/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"3744fc1666c41aeb4ed44f31605bafdb413b42bc" 3744fc1]:
{{{
#!CommitTicketReference repository=""
revision="3744fc1666c41aeb4ed44f31605bafdb413b42bc"
[1.10.x] Fixed #26917 -- Fixed crash in disabled ModelChoiceFields.

Partially reverted refs #25532 to fix a regression in Django 1.10.
This reintroduces a crash for disabled forms.JSONField (refs #26949),
however, that issue is also present on Django 1.9.

Thanks Ryan Schave for the test.

Backport of a5f85d891b51d7ceb4f9e422e3e4f5c741062288 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26949#comment:8>

Django

unread,
Jul 27, 2016, 8:49:04 AM7/27/16
to django-...@googlegroups.com
#26949: Disabled forms.JSONField crashes with TypeError
----------------------------------+------------------------------------
Reporter: timgraham | Owner: alexyer
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"714e287d9a2b8ca7668a951e7193d9bbae3c3162" 714e287d]:
{{{
#!CommitTicketReference repository=""
revision="714e287d9a2b8ca7668a951e7193d9bbae3c3162"
[1.10.x] Fixed #26949 -- Fixed crash of disabled forms.JSONField.

Backport of 68de48c96328e13d5dbdb1f3006e4a1ca74f3c34 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages