Thursday, September 18, 2014

django 1.7: inlines not deleted when save_formset is overridden

I've modified an Admin with code similar to the following:

    def save_formset(self, request, form, formset, change):          instances = formset.save(commit=False)          for instance in instances:              instance.user = request.user              instance.save()          formset.save_m2m()


The problem I'm having is that if a "delete" checkbox is checked, the inline does not get deleted. I tracked this down to forms/models.py:save_existing_objects(). In Django 1.5 it deleted objects regardless of the setting of the commit argument. In django 1.7, it does not delete the objects if commit==False.

Am I missing something in the above that I need to do in order to cause my deleted inlines to be deleted? I can do it by looping through formset.deleted_forms myself (basically duplicating the code from save_existing_objects), but this feels like the wrong way to go about it.

Thanks,
Scott

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2e6b89cb-9850-428e-b718-9d4fe1db0c27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment