I am using this post as a reference: Django: Adding inline formset rows without javascript
if request.method=='POST':
PrimaryFunctionFormSet = inlineformset_factory(Position,Function)
if 'add' in request.POST:
cp = request.POST.copy()
cp['prim-TOTAL_FORMS'] = int(cp['prim-TOTAL_FORMS'])+ 1
prims = PrimaryFunctionFormSet(cp,prefix='prim')
I am trying to add inlines rows without javascript and came across a few things I didn't understand in the implementation referenced above.
- How do you get a button called 'add' in your form or view or template?
- 'prims' was defined in the form but 'prim-TOTAL_FORMS' was not. Do you need to define 'prim-TOTAL_FORMS' somewhere?
- How can you call 'prim-TOTAL_FORMS' before you defined 'prim'?
- Is this all writtein in the views.py?
Thanks for the help, and sorry if the questions are novice!