Can I use multiple numbers in one form in django, if so, how?

I need to make a form that uses more than one set of forms. please tell me if this is possible. if so, how?

+6
source share
2 answers

You can add as many forms to a form. Just create / run them in sight and go to the template for rendering in the form.

Sort of:

{{ formset1.management_form }}
{% for form in formset1 %}
    {{ form }}
{% endfor %}

{{ formset2.management_form }}
{% for form in formset2 %}
    {{ form }}
{% endfor %}

You are using multiple forms in one view, you need to use a prefix for the forms as described here Using multiple forms in a view In short:

article_formset = ArticleFormSet(prefix='articles')
book_formset = BookFormSet(prefix='books')
+11
source

= 'article' , , ,

<label for="id_form-0-title">Title:</label> 

<label for="id_article-0-title">Title:</label>
0

All Articles