The Django documentation says that "As shown above you can define the number of extra forms. What this means is that you are telling the formset how many additional forms to show in addition to the number of forms it generates from the initial data." Source here.
However, (at least) with inline formsets, that doesn't seem to be the case. It looks like the extra
parameter determines the total number of forms. If I write extra=0
I'll simply have no forms at all to show, with extra=1
I'll only get the first one, and so on. Seems like you have to set extra to the length of the initial data (not very DRY, is it?)
Some examples where people do the same thing (extra=len(myinitial)
):
- Different initial data for each form in a Django formset
- formset and input text for each foreign key
- Initial Data for Django Inline Formsets
The question is: Am I missing anything in the documentation or why does this make sense?
Note. I'm not including source code because I'm developing with django-extra-views with adds additional complexity to the sample code. Nonetheless, the few examples around seem to point to the same thing. (I'm not sure what I did with previous projects, though, but I think that I encountered the same problem with plain inline form sets).