I want to add an onchange event to the formset, I tried to do this in views.py, but it adds this error to me:
'name':input(attrs={
TypeError: input() takes no keyword arguments
views.py
ParteFormSet = formset_factory(ParteForm, extra=extra_forms, max_num=20, widgets={
'name':input(attrs={
'onchange': 'multiplicar()'
})
})
formset = ParteFormSet()
CodePudding user response:
First, you have to define the widget in the parent form ('ParteForm'), not in the formset_factory function.
Second, input()
is not a Django widget. Actually, you're invoking Python's input() function, which is definitely not what you want.
Instead use a valid Django built-in widget class (see list here). For example, forms.TextInput()
.