[Django] #27220: MultiWidget not considered in form submit

4 views
Skip to first unread message

Django

unread,
Sep 13, 2016, 3:50:09 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
----------------------------+--------------------
Reporter: andreage | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
I have a custom widget for a field, for example:

{{{
class TestWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (
Select(choices=func_start()),
Select(choices=func_end())
)
super(TestWidget, self).__init__(widgets, attrs)

...


class TestModel(models.Model)
test = ArrayField(models.PositiveSmallIntegerField(), default=list,
blank=True)


class TestForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)
self.fields['test'].widget = SlotsWidget(self.facility)
}}}

It's been working fine until Django 10.0. With Django 10.1 and
specifically due to this commit it breaks.

https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
#diff-70af885c2725fe87eb3b99a393268d10

`f.name` in this commit would be "test", but `form.data` would contain
"test_0" and "test_1". For this reason form content is skipped and not
saved to the form instance.

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

Django

unread,
Sep 13, 2016, 3:51:17 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------

Reporter: andreage | 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 andreage):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

> I have a custom widget for a field, for example:
>
> {{{
> class TestWidget(MultiWidget):
> def __init__(self, attrs=None):
> widgets = (
> Select(choices=func_start()),
> Select(choices=func_end())
> )
> super(TestWidget, self).__init__(widgets, attrs)
>
> ...
>

> class TestModel(models.Model)
> test = ArrayField(models.PositiveSmallIntegerField(), default=list,
> blank=True)
>

> class TestForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(TestForm, self).__init__(*args, **kwargs)
> self.fields['test'].widget = SlotsWidget(self.facility)
> }}}
>
> It's been working fine until Django 10.0. With Django 10.1 and
> specifically due to this commit it breaks.
>
> https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
> #diff-70af885c2725fe87eb3b99a393268d10
>
> `f.name` in this commit would be "test", but `form.data` would contain
> "test_0" and "test_1". For this reason form content is skipped and not
> saved to the form instance.

New description:

I have a custom widget for a field, for example:

{{{
class TestWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (
Select(choices=func_start()),
Select(choices=func_end())
)
super(TestWidget, self).__init__(widgets, attrs)

...


class TestModel(models.Model)
test = ArrayField(models.PositiveSmallIntegerField(), default=list,
blank=True)


class TestForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)
self.fields['test'].widget = SlotsWidget(self.facility)
}}}

It's been working fine until Django 10.0. With Django 10.1 and
specifically due to this commit it breaks.

https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
#diff-70af885c2725fe87eb3b99a393268d10

`f.name` in this commit would be "test", but `form.data` would contain

"test_0" and "test_1". For this reason form field content is skipped and


not saved to the form instance.

--

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

Django

unread,
Sep 13, 2016, 3:51:45 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------

Reporter: andreage | 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
--------------------------+--------------------------------------
Description changed by andreage:

Old description:

> I have a custom widget for a field, for example:
>
> {{{
> class TestWidget(MultiWidget):
> def __init__(self, attrs=None):
> widgets = (
> Select(choices=func_start()),
> Select(choices=func_end())
> )
> super(TestWidget, self).__init__(widgets, attrs)
>
> ...
>

> class TestModel(models.Model)
> test = ArrayField(models.PositiveSmallIntegerField(), default=list,
> blank=True)
>

> class TestForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(TestForm, self).__init__(*args, **kwargs)
> self.fields['test'].widget = SlotsWidget(self.facility)
> }}}
>
> It's been working fine until Django 10.0. With Django 10.1 and
> specifically due to this commit it breaks.
>
> https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
> #diff-70af885c2725fe87eb3b99a393268d10
>
> `f.name` in this commit would be "test", but `form.data` would contain

> "test_0" and "test_1". For this reason form field content is skipped and


> not saved to the form instance.

New description:

I have a custom widget for a field, for example:

{{{
class TestWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (
Select(choices=func_start()),
Select(choices=func_end())
)
super(TestWidget, self).__init__(widgets, attrs)

...


class TestModel(models.Model)
test = ArrayField(models.PositiveSmallIntegerField(), default=list,
blank=True)


class TestForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)
self.fields['test'].widget = SlotsWidget(self.facility)
}}}

It's been working fine until Django 10.0. With Django 10.1 and
specifically due to this commit it breaks.

https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
#diff-70af885c2725fe87eb3b99a393268d10

`f.name` in this commit would be "test", but `form.data` would contain

"test_0" and "test_1". For this reason form field content is skipped and
not saved to the model instance.

--

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

Django

unread,
Sep 13, 2016, 3:52:47 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------

Reporter: andreage | 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
--------------------------+--------------------------------------
Description changed by andreage:

Old description:

> I have a custom widget for a field, for example:


>
> {{{
> class TestWidget(MultiWidget):
> def __init__(self, attrs=None):
> widgets = (
> Select(choices=func_start()),
> Select(choices=func_end())
> )
> super(TestWidget, self).__init__(widgets, attrs)
>
> ...
>

> class TestModel(models.Model)
> test = ArrayField(models.PositiveSmallIntegerField(), default=list,
> blank=True)
>

> class TestForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(TestForm, self).__init__(*args, **kwargs)
> self.fields['test'].widget = SlotsWidget(self.facility)
> }}}
>
> It's been working fine until Django 10.0. With Django 10.1 and
> specifically due to this commit it breaks.
>
> https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
> #diff-70af885c2725fe87eb3b99a393268d10
>
> `f.name` in this commit would be "test", but `form.data` would contain

> "test_0" and "test_1". For this reason form field content is skipped and
> not saved to the model instance.

New description:

I have a custom widget for a field, for example:

{{{
class TestWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (
Select(choices=func_start()),
Select(choices=func_end())
)
super(TestWidget, self).__init__(widgets, attrs)

...


class TestModel(models.Model)
test = ArrayField(models.PositiveSmallIntegerField(), default=list,
blank=True)


class TestForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)

self.fields['test'].widget = TestWidget(self.facility)
}}}

It's been working fine until Django 10.0. With Django 10.1 and
specifically due to this commit it breaks.

https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
#diff-70af885c2725fe87eb3b99a393268d10

`f.name` in this commit would be "test", but `form.data` would contain

"test_0" and "test_1". For this reason form field content is skipped and
not saved to the model instance.

--

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

Django

unread,
Sep 13, 2016, 3:53:29 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------

Reporter: andreage | 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
--------------------------+--------------------------------------
Description changed by andreage:

Old description:

> I have a custom widget for a field, for example:


>
> {{{
> class TestWidget(MultiWidget):
> def __init__(self, attrs=None):
> widgets = (
> Select(choices=func_start()),
> Select(choices=func_end())
> )
> super(TestWidget, self).__init__(widgets, attrs)
>
> ...
>

> class TestModel(models.Model)
> test = ArrayField(models.PositiveSmallIntegerField(), default=list,
> blank=True)
>

> class TestForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(TestForm, self).__init__(*args, **kwargs)

> self.fields['test'].widget = TestWidget(self.facility)


> }}}
>
> It's been working fine until Django 10.0. With Django 10.1 and
> specifically due to this commit it breaks.
>
> https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
> #diff-70af885c2725fe87eb3b99a393268d10
>
> `f.name` in this commit would be "test", but `form.data` would contain

> "test_0" and "test_1". For this reason form field content is skipped and
> not saved to the model instance.

New description:

I have a custom widget for a field, for example:

{{{
class TestWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (
Select(choices=func_start()),
Select(choices=func_end())
)
super(TestWidget, self).__init__(widgets, attrs)

...


class TestModel(models.Model)
test = ArrayField(models.PositiveSmallIntegerField(), default=list,
blank=True)


class TestForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)

self.fields['test'].widget = TestWidget()
}}}

It's been working fine until Django 10.0. With Django 10.1 and
specifically due to this commit it breaks.

https://github.com/django/django/commit/4bc6b939944183533ae74791d21282e613f63a96
#diff-70af885c2725fe87eb3b99a393268d10

`f.name` in this commit would be "test", but `form.data` would contain

"test_0" and "test_1". For this reason form field content is skipped and
not saved to the model instance.

--

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

Django

unread,
Sep 13, 2016, 3:54:34 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------

Reporter: andreage | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
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 andreage):

* version: 1.10 => master


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

Django

unread,
Sep 13, 2016, 4:00:13 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------

Reporter: andreage | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
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 andreage):

See also https://code.djangoproject.com/ticket/27186

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

Django

unread,
Sep 13, 2016, 4:02:43 PM9/13/16
to django-...@googlegroups.com
#27220: MultiWidget not considered in form submit
--------------------------+--------------------------------------
Reporter: andreage | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: duplicate
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 timgraham):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #27186. Please check the patch there.

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

Reply all
Reply to author
Forward
0 new messages