[Django] #26917: Disabled fields don't validate anymore in 1.10

15 views
Skip to first unread message

Django

unread,
Jul 19, 2016, 12:58:30 PM7/19/16
to django-...@googlegroups.com
#26917: Disabled fields don't validate anymore in 1.10
-------------------------------+--------------------
Reporter: karyon | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
i have several tests that fail when trying to submit a form that has
disabled fields in 1.10, which worked in 1.9, and also works when making
it disabled=False. example stacktrace:

{{{
Traceback (most recent call last):
File "/vagrant/evap/staff/tests/test_forms.py", line 105, in
test_single_result_form_saves_participant_and_voter_count
self.assertTrue(form.is_valid())
File "/vagrant/src/django/django/forms/forms.py", line 161, in is_valid
return self.is_bound and not self.errors
File "/vagrant/src/django/django/forms/forms.py", line 153, in errors
self.full_clean()
File "/vagrant/src/django/django/forms/forms.py", line 364, in
full_clean
self._post_clean()
File "/vagrant/src/django/django/forms/models.py", line 401, in
_post_clean
self.instance = construct_instance(self, self.instance, opts.fields,
opts.exclude)
File "/vagrant/src/django/django/forms/models.py", line 60, in
construct_instance
f.save_form_data(instance, cleaned_data[f.name])
File "/vagrant/src/django/django/db/models/fields/__init__.py", line
867, in save_form_data
setattr(instance, self.name, data)
File
"/vagrant/src/django/django/db/models/fields/related_descriptors.py", line
203, in __set__
self.field.remote_field.model._meta.object_name,
ValueError: Cannot assign "1": "Course.semester" must be a "Semester"
instance.
}}}

code for the form is [https://github.com/fsr-
itse/EvaP/blob/b6222413f15fc7256622a31f7045046f7be1e466/evap/staff/forms.py#L149
here] (it's about the semester attribute, and ignore the two methods, this
also fails when removing those) and test is [https://github.com/fsr-
itse/EvaP/blob/b6222413f15fc7256622a31f7045046f7be1e466/evap/staff/tests/test_forms.py#L104
here].

this regressed in db19619545dd99a1d2502c72974d79eca33acff7.

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

Django

unread,
Jul 19, 2016, 2:11:45 PM7/19/16
to django-...@googlegroups.com
#26917: Disabled fields don't validate anymore in 1.10
------------------------+--------------------------------------

Reporter: karyon | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------+--------------------------------------
Changes (by karyon):

* needs_better_patch: => 0
* component: Uncategorized => Forms
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Jul 19, 2016, 3:01:05 PM7/19/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------

Reporter: karyon | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Release blocker | 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 timgraham):

* stage: Unreviewed => Accepted
* severity: Normal => Release blocker


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

Django

unread,
Jul 19, 2016, 5:41:50 PM7/19/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: assigned

Component: Forms | Version: 1.10
Severity: Release blocker | 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 rjschave):

* status: new => assigned
* owner: nobody => rjschave


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

Django

unread,
Jul 20, 2016, 1:56:55 AM7/20/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: assigned
Component: Forms | Version: 1.10
Severity: Release blocker | 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 rjschave):

* Attachment
"Refs__26917___Added_test_to_duplicate_problem___Added_test_to_duplicate_problem_in_which_a.patch"
added.

Added unit test to duplicate problem

Django

unread,
Jul 20, 2016, 3:45:38 PM7/20/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: assigned
Component: Forms | Version: 1.10
Severity: Release blocker | 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 timgraham):

* cc: claudep (added)


Comment:

Claude, I'm not sure how to proceed here. It seems that the assumption
about "Initial values are supposed to be clean" isn't correct for foreign
keys. They're converted to primary key in `model_to_dict` and (previously)
back to model instances in `clean()`. Now that latter conversion is
skipped.

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

Django

unread,
Jul 20, 2016, 4:41:04 PM7/20/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: assigned
Component: Forms | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by claudep):

If we don't find a better solution, we could partially revert that faulty
part of the patch, like I did when backporting to 1.9 (#25532). But then a
disabled `JSONField` will be non-functional. It may be less critical,
though.

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

Django

unread,
Jul 25, 2016, 3:10:54 PM7/25/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: assigned
Component: Forms | Version: 1.10
Severity: Release blocker | 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:

[https://github.com/django/django/pull/6972 PR] to partially revert and
add the regression test from Ryan.

I created #26949 for the issue about disabled `JSONField`'s crashing.

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

Django

unread,
Jul 27, 2016, 8:36:24 AM7/27/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: closed
Component: Forms | Version: 1.10
Severity: Release blocker | 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:"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/26917#comment:7>

Django

unread,
Jul 27, 2016, 8:43:15 AM7/27/16
to django-...@googlegroups.com
#26917: Disabled ModelChoiceFields crash in Django 1.10
---------------------------------+------------------------------------
Reporter: karyon | Owner: rjschave
Type: Bug | Status: closed
Component: Forms | Version: 1.10
Severity: Release blocker | 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/26917#comment:8>

Reply all
Reply to author
Forward
0 new messages