1👍
✅
When you call add_inputs
, the code appends the input to self.inputs
. So a quick hack would be to pop the existing input from the list before adding the new one.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
...
self.inputs.pop()
self.helper.add_input(...)
However this is fragile, because it assumes that there is exactly one input. It might be better to have a BaseSupplierForm
which does not have any inputs, then have two subclasses SupplierRegistrationSupplementForm
and SupplierUpdateForm
, which both define their own inputs.
Source:stackexchange.com