--- a/django/db/models/deletion.py.orig	2017-04-19 12:06:55.693904400 +0200
+++ b/django/db/models/deletion.py	2017-04-19 12:06:31.022437500 +0200
@@ -287,7 +287,12 @@
             # update fields
             for model, instances_for_fieldvalues in six.iteritems(self.field_updates):
                 query = sql.UpdateQuery(model)
-                for (field, value), instances in six.iteritems(instances_for_fieldvalues):
+                items = instances_for_fieldvalues.items()
+                import random
+                random.shuffle(items)
+                items = OrderedDict(items)
+                for (field, value), instances in six.iteritems(items):
+                    print field.name, value, instances
                     query.update_batch([obj.pk for obj in instances],
                                        {field.name: value}, self.using)
 
diff --git a/tests/delete_regress/models.py b/tests/delete_regress/models.py
index f0145de..1e6da6b 100644
--- a/tests/delete_regress/models.py
+++ b/tests/delete_regress/models.py
@@ -139,3 +139,41 @@ class OrderedPerson(models.Model):
 
     class Meta:
         ordering = ['name']
+
+def organization_on_delete(collector, field, sub_objs, using):
+    deleted_objs = sub_objs.filter(report__isnull=True)
+    ignored_objs = sub_objs.filter(report__isnull=False)
+    collector.add_field_update(field, None, ignored_objs)
+    models.CASCADE(collector, field, deleted_objs, using)
+    
+
+class Organization(models.Model):
+    name = models.CharField(max_length=255)
+    
+class Report(models.Model):
+    name = models.CharField(max_length=255)
+    
+class ThreatenedOrganization(models.Model):
+    organization = models.ForeignKey(Organization, null=True, blank=True,
+                                     on_delete=organization_on_delete)
+    organization_name = models.CharField(max_length=255)
+    report = models.ForeignKey(Report, null=True, blank=True)
+
+    def __unicode__(self):
+        if self.report_id:
+            return 'reported threatened org'
+        return 'threatened org'
+    
+class CostClaim(models.Model):
+    organization = models.ForeignKey(Organization, null=True, blank=True,
+                                     on_delete=organization_on_delete)
+    organization_name = models.CharField(max_length=255)
+    report = models.ForeignKey(Report, null=True, blank=True)
+    threatened = models.ForeignKey(ThreatenedOrganization, null=True, blank=True,
+                                   on_delete=models.SET_NULL)
+
+    def __unicode__(self):
+        if self.report_id:
+            return 'reported cost claim'
+        return 'cost claim'
+    
diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py
index 7472731..01257ba 100644
--- a/tests/delete_regress/tests.py
+++ b/tests/delete_regress/tests.py
@@ -7,7 +7,8 @@ from .models import (
     Award, AwardNote, Book, Child, Eaten, Email, File, Food, FooFile,
     FooFileProxy, FooImage, FooPhoto, House, Image, Item, Location, Login,
     OrderedPerson, OrgUnit, Person, Photo, PlayedWith, PlayedWithNote, Policy,
-    Researcher, Toy, Version,
+    Researcher, Toy, Version, Organization, Report, ThreatenedOrganization,
+    CostClaim
 )
 
 
@@ -343,3 +344,40 @@ class OrderedDeleteTests(TestCase):
         OrderedPerson.objects.create(name='Bob', lives_in=h)
         OrderedPerson.objects.filter(lives_in__address='Foo').delete()
         self.assertEqual(OrderedPerson.objects.count(), 0)
+
+class CollectorUpdateTests(TestCase):
+    def test_delete_with_custom_handlers(self):
+
+        org, _ = Organization.objects.get_or_create(name="test org")
+
+        t_org, _ = ThreatenedOrganization.objects.get_or_create(
+            organization=org, organization_name="test org",
+            report=None)
+
+        cost_claim, _ = CostClaim.objects.get_or_create(
+            organization=org, organization_name="test org",
+            threatened=t_org, report=None)
+
+        report, _ = Report.objects.get_or_create(name="test report")
+
+        t_org_in_report, _ = ThreatenedOrganization.objects.get_or_create(
+            organization=org, organization_name="test org",
+            report=report)
+
+        cost_claim_in_report, _ = CostClaim.objects.get_or_create(
+            organization=org, organization_name="test org",
+            threatened=t_org_in_report, report=report)
+
+        org.delete()
+
+        try:
+            cost_claim = CostClaim.objects.get(id = cost_claim.pk)
+            self.assertTrue(False)
+        except CostClaim.DoesNotExist:
+            self.assertTrue(True)
+
+        cost_claim_in_report = CostClaim.objects.get(
+            id = cost_claim_in_report.pk)
+        self.assertEqual(cost_claim_in_report.threatened_id, t_org_in_report.pk)
+        self.assertEqual(cost_claim_in_report.report_id, report.pk)
+        self.assertEqual(cost_claim_in_report.organization_id, None)
