DEV Community

Discussion on: Django inline formsets with Class-based views and crispy forms

Collapse
 
kingraphaii profile image
Percival Rapha

Thank you so much for this tut. How can i limit the number of forms in the form set that can be added?

Collapse
 
zxenia profile image
Xenia

Thanks!
When you create you inline formset you can limit the number of forms in the formset with max_num parameter

e.g.

CollectionTitleFormSet = inlineformset_factory(
    Collection, CollectionTitle, form=CollectionTitleForm,
    fields=['name', 'language'], extra=1, max_num=3, can_delete=True
    )