[Django]-Adding new forms to a Django formset based on POST data

2👍

In your views.py:

-            formset = DepositFormSet(initial=formset.cleaned_data)
+            data = formset.cleaned_data
+            if data[-1]=={}:
+                data=data[:-1]
+            formset = DepositFormSet(initial=data)

It looks pretty much like a feature than like a bug 😉

1👍

I’ve not done this myself, but if you wanted to actually make it invalid with a blank entry, perhaps you’d consider putting it in the clean method:

http://docs.djangoproject.com/en/dev/topics/forms/formsets/#custom-formset-validation

Leave a comment