tags:

views:

214

answers:

1

I have an inlineformset which displays a maximum of 10 forms. But when I try to save/update the formset these extra objects ( which are blank in content ) also get saved. So everytime the formset is saved/edited these blank records keep entering into the database. What could the reason be ?

+3  A: 

In your view when you get a POST with a formset you have to check each form to make sure it has changed (this way empties will get disregarded). I also include an additional check for deleted forms if you have delete enabled:

for form in formset.forms:
  if form.has_changed():
       if not form in formset.deleted_forms:
            # Do something with this form
drozzy