Opened 8 years ago
Last modified 8 years ago
#27220 closed Bug
MultiWidget not considered in form submit — at Version 3
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(self.facility)
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 (3)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
Description: | modified (diff) |
---|
comment:3 by , 8 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.