Opened 9 years ago
Closed 9 years ago
#27220 closed Bug (duplicate)
MultiWidget not considered in form submit
| Reported by: | Andrea Angelini | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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.
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.
Change History (7)
comment:1 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:4 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:5 by , 9 years ago
| Version: | 1.10 → master |
|---|
comment:6 by , 9 years ago
comment:7 by , 9 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Duplicate of #27186. Please check the patch there.
Note:
See TracTickets
for help on using tickets.
See also https://code.djangoproject.com/ticket/27186