1👍
✅
Alasdair’s suggestion (formset) is a way to generate multiple instances of the same form at once.
The forms can be rendered in the template by looping over the formset instance:
{% for form in formset %}
{{ form.id }} #PK field is MANDATORY, see reference[2] below
{{ form.field1 }}
{{ form.field2 }} #or just as something {{ form.as_p }}
{% endfor %}
In your views, formset validation is made once for all if formset.is_valid():
and rformset = formset_factory(MyUsers, extra=1, max_num=3)
to create the formset.
Don’t forget the imports.
References, both from Django Docs:
Formsets {1}
Source:stackexchange.com