formsets code example

Example 1: inline formset plus

<h3>FormSet example</h3>
{{ myformset.management_form }}
<div id="form_set">
    {% for form in myformset.forms %}
	    {{form.non_field_errors}}
		{{form.errors}}
        <table class='no_error'>
            {{ form }}
        </table>
    {% endfor %}
</div>
<input type="button" value="Add More" id="add_more">
<div id="empty_form" style="display:none">
    <table class='no_error'>
        {{ myformset.empty_form }}
    </table>
</div>

Example 2: inline formset plus

$('#add_more').click(function() {
	var form_idx = $('#id_form-TOTAL_FORMS').val();
	$('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx));
	$('#id_form-TOTAL_FORMS').val(parseInt(form_idx) + 1);
});