check-in fix for checkbox deletion not working in django 1.7
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 6fcc3f9..94e8453 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -419,6 +419,24 @@
instances = formset.save(commit=False)
for instance in instances:
instance.save_by_user(request.user)
+
+ # BUG in django 1.7? Objects are not deleted by formset.save if
+ # commit is False. So let's delete them ourselves.
+ #
+ # code from forms/models.py save_existing_objects()
+ try:
+ forms_to_delete = formset.deleted_forms
+ except AttributeError:
+ forms_to_delete = []
+ if formset.initial_forms:
+ for form in formset.initial_forms:
+ obj = form.instance
+ if form in forms_to_delete:
+ if obj.pk is None:
+ continue
+ formset.deleted_objects.append(obj)
+ obj.delete()
+
formset.save_m2m()
class SliceRoleAdmin(PlanetStackBaseAdmin):