              for related_model, instances in self.data.items():
                  self.clear_restricted_objects_from_set(related_model, instances)
              for qs in self.fast_deletes:
                  self.clear_restricted_objects_from_queryset(qs.model, qs)
              for model, fields in self.restricted_objects.items():
                  for field, objs in fields.items():
                      for obj in objs:
                          raise RestrictedError(
                              "Cannot delete some instances of model '%s' "
                              "because they are referenced through a restricted "
                              "foreign key: '%s.%s'." % (
                                  field.remote_field.model.__name__,
                                  obj.__class__.__name__,
                                  field.name,
                              ),
                              objs,
                          )
  
      def related_objects(self, related_model, related_fields, objs):
          """
          Get a QuerySet of the related model to objs via related fields.
          """
 
</s> remove             "referenced through a restricted foreign key: 'A.restrict'."
 </s> add             "referenced through restricted foreign keys: 'A.restrict'."
        )
        with self.assertRaisesMessage(RestrictedError, msg):
            a.restrict.delete()

    def test_restrict_multiple(self):
        a = create_a('restrict')
        B3.objects.create(restrict=a.restrict)
        msg = (
            "Cannot delete some instances of model 'R' because they are "
            "referenced through restricted foreign keys: 'A.restrict', "
            "'B3.restrict'." </s> remove             "Cannot delete some instances of model 'R' because they are "
            "referenced through a restricted foreign key: 'A.restrict'."
 </s> add             "Cannot delete some instances of model 'P' because they are "
            "referenced through restricted foreign keys: 'A.restrict'." </s> remove             "are referenced through a restricted foreign key: "
 </s> add             "are referenced through restricted foreign keys: " </s> remove             "referenced through a restricted foreign key: 'DeleteBottom.b1'."
 </s> add             "referenced through restricted foreign keys: 'DeleteBottom.b1'." </s> remove     B1, B2, MR, A, Avatar, B, Base, Child, DeleteBottom, DeleteTop, GenericB1,
    GenericB2, GenericDeleteBottom, HiddenUser, HiddenUserProfile, M, M2MFrom,
    M2MTo, MRNull, Origin, P, Parent, R, RChild, RChildChild, Referrer, S, T,
    User, create_a, get_default_r,
 </s> add     B1, B2, B3, MR, A, Avatar, B, Base, Child, DeleteBottom, DeleteTop,
    GenericB1, GenericB2, GenericDeleteBottom, HiddenUser, HiddenUserProfile,
    M, M2MFrom, M2MTo, MRNull, Origin, P, Parent, R, RChild, RChildChild,
    Referrer, S, T, User, create_a, get_default_r,
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
              for related_model, instances in self.data.items():
                  self.clear_restricted_objects_from_set(related_model, instances)
              for qs in self.fast_deletes:
                  self.clear_restricted_objects_from_queryset(qs.model, qs)
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
            if self.restricted_objects.values():
                restricted_objects = defaultdict(list)
                for related_model, fields in self.restricted_objects.items():
                    for field, objs in fields.items():
                        if objs:
                            key = "'%s.%s'" % (related_model.__name__, field.name)
                            restricted_objects[key] += objs
                if restricted_objects:
                    raise RestrictedError(
                        'Cannot delete some instances of model %r because '
                        'they are referenced through restricted foreign keys: '
                        '%s.' % (
                            model.__name__,
                            ', '.join(restricted_objects),
                        ),
                        chain.from_iterable(restricted_objects.values()),
                    )
  
      def related_objects(self, related_model, related_fields, objs):
          """
          Get a QuerySet of the related model to objs via related fields.
          """
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Refs #27852 -- Fixed object deletion to show all restricted related objects rather than just the first one. 
django/db/models/deletion.py