[Django] #28387: Disabled fields should not be considered changed in bound forms

9 views
Skip to first unread message

Django

unread,
Jul 11, 2017, 6:18:39 PM7/11/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
----------------------------------------+------------------------
Reporter: Kevin Corbin | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
This is similar to #27431, but that ticket only modified the has_changed
method in the base django.forms.fields.Field class.

Other form field classes included in django.forms.fields and
django.forms.models override the base class' has_changed method, so aren't
checking for the disabled attribute when determining whether or not a
bound form field's data has changed.

As of Django 1.11.3, the following are affected:
*django.forms.fields.BooleanField
*django.forms.fields.MultipleChoiceField
*django.forms.fields.MultiValueField
*django.forms.fields.FileField
*django.forms.models.ModelChoiceField
*django.forms.models.ModelMultipleChoiceField

Here is an example form class that exhibits this behavior:
{{{#!python
from django.contrib.auth import get_user_model
class MyTestForm(forms.Form):
test_disabled = forms.ModelChoiceField(disabled=True,
queryset=get_user_model().objects.all(),
initial=get_user_model().objects.first().id)
}}}

From the console I show the bug as such:
{{{#!python
form = MyTestForm(data={})
form.is_bound #True
form.has_changed() #True
form.changed_data #['test_disabled']
}}}

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

Django

unread,
Jul 13, 2017, 10:45:49 AM7/13/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
-------------------------------------+-------------------------------------
Reporter: Kevin Corbin | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: assigned
Component: Forms | Version: 1.11
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 Srinivas Reddy Thatiparthy):

* owner: nobody => Srinivas Reddy Thatiparthy
* status: new => assigned


Comment:

Will submit a PR soon.

Thanks,
Srini

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

Django

unread,
Jul 13, 2017, 10:59:00 AM7/13/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
-------------------------------------+-------------------------------------
Reporter: Kevin Corbin | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: assigned
Component: Forms | Version: 1.11
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
-------------------------------------+-------------------------------------

Comment (by Srinivas Reddy Thatiparthy):

PR has been raised here https://github.com/django/django/pull/8761

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

Django

unread,
Jul 13, 2017, 1:58:19 PM7/13/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
-------------------------------------+-------------------------------------
Reporter: Kevin Corbin | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: assigned
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


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

Django

unread,
Jul 13, 2017, 2:48:14 PM7/13/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
-------------------------------------+-------------------------------------
Reporter: Kevin Corbin | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: assigned
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted


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

Django

unread,
Jul 14, 2017, 1:27:39 PM7/14/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
-------------------------------------+-------------------------------------
Reporter: Kevin Corbin | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: closed
Component: Forms | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

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


Comment:

In [changeset:"5debbdfcc84266703191e084914998e38f5f52eb" 5debbdfc]:
{{{
#!CommitTicketReference repository=""
revision="5debbdfcc84266703191e084914998e38f5f52eb"
Fixed #28387 -- Fixed has_changed() for disabled form fields that subclass
it.
}}}

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

Django

unread,
Jul 14, 2017, 1:34:43 PM7/14/17
to django-...@googlegroups.com
#28387: Disabled fields should not be considered changed in bound forms
-------------------------------------+-------------------------------------
Reporter: Kevin Corbin | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: closed
Component: Forms | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

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

In [changeset:"a3b5df8ed503ea559d2ffaca7ec0c735d98f1a38" a3b5df8]:
{{{
#!CommitTicketReference repository=""
revision="a3b5df8ed503ea559d2ffaca7ec0c735d98f1a38"
[1.11.x] Fixed #28387 -- Fixed has_changed() for disabled form fields that
subclass it.

Backport of 5debbdfcc84266703191e084914998e38f5f52eb from master
}}}

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

Reply all
Reply to author
Forward
0 new messages