"extra" parameter does not add any extra lines in inline formset with initial data
|Reported by:||mardy@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have an inline formset, created with inlineformset_factory with extra=1. When editing the form, I always want to have one empty form in case the user wants to add a row.
My code looks like this:
DSAFormSet = inlineformset_factory(Image, DSA, extra=1) if request.method == 'POST': dsa_formset = DSAFormSet(request.POST, instance=image, prefix='dsa') if dsa_formset.is_valid(): dsa_formset.save() else: dsa_formset = DSAFormSet(instance=image, prefix='dsa')
The first time the page is loaded, we hit the "else" branch, and everything works fine: we get one extra blank form. But when the user fills it and resubmits the formset, no extra row is added.