Opened 13 years ago
Closed 12 years ago
#17416 closed Bug (fixed)
inlineformset_factory doesn't allow the widgets argument
Reported by: | Jacob | Owned by: | Nick Sandford |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
modelformset_factory
supports a widgets
argument for specifying custom widgets in the created forms, so I expected inlineformset_factory
to do the same. That is, I tried this:
ChoiceFormset = inlineformset_factory(Poll, Choice, widgets = {'order': forms.HiddenInput})
No dice: inlineformset_factory() got an unexpected keyword argument 'widgets'
.
I think this is just a simple omission since inlineformset_factory
is a thin wrapper over modelformset_factory
but I haven't investigated the history to see if this argument was an intentional or unintentional omission.
Change History (5)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 years ago
comment:3 by , 12 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Version: | 1.3 → master |
Added code, tests and documentation into a similar ticket's (#19569) pull request here: https://github.com/django/django/pull/630.
comment:4 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
There is a work around for this bug/feature,
1) Create a ModelForm with the requested widget
2) Pass the ModelForm as form argument and voila, the widget works
in models.py
class SomeForm(ModelForm):
in views.py
SomeFormsetFactory = inlineformset_factory(Parent, Something, form=SomeForm)