Opened 8 years ago
Last modified 8 years ago
#27220 closed Bug
MultiWidget not considered in form submit — at Initial Version
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
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.
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.
Note:
See TracTickets
for help on using tickets.