I would like to create an empty formset with fixed number ( more than 1) I am not sure is it possible to do it in views.py. I saw many methods using jquery to create a new form.
here is my code to create a new form, however the number of form is only one.
MyStuffSet = modelformset_factory( MyStuff )
formset = MyStuffSet( queryset = MyStuff.objects.none() )
You can use extra
parameter . like :
MyStuffSet = modelformset_factory(MyStuff, extra=3)
OR Condition based :
MyStuffSet = modelformset_factory(MyStuff, extra=1 if request.POST.has_key('any_key') else 0)
I would like to create an empty formset with fixed number ( more than 1) I am not sure is it possible to do it in views.py. I saw many methods using jquery to create a new form.
here is my code to create a new form, however the number of form is only one.
MyStuffSet = modelformset_factory( MyStuff )
formset = MyStuffSet( queryset = MyStuff.objects.none() )
You can use extra
parameter . like :
MyStuffSet = modelformset_factory(MyStuff, extra=3)
OR Condition based :
MyStuffSet = modelformset_factory(MyStuff, extra=1 if request.POST.has_key('any_key') else 0)
0 commentaires:
Enregistrer un commentaire