Dynamically adding a form to a Django formset with Ajax

后端 未结 15 1928
不思量自难忘°
不思量自难忘° 2020-11-22 03:09

I want to automatically add new forms to a Django formset using Ajax, so that when the user clicks an \"add\" button it runs JavaScript that adds a new form (which is part o

15条回答
  •  难免孤独
    2020-11-22 03:37

    Simplified version of Paolo's answer using empty_form as a template.

    My Services

    {{ serviceFormset.management_form }}
    {% for form in serviceFormset.forms %} {{ form.as_table }}
    {% endfor %}

提交回复
热议问题