code: def get_deleted_objects(objs, opts, user, admin_site, using):
      
      # --- begin patch ---
      collector = PolymorphicAwareNestedObjects(using=using)
      # --- end patch ---
      collector.collect(objs)
      perms_needed = set()
  
      def format_callback(obj):
          has_admin = obj.__class__ in admin_site._registry
          opts = obj._meta
  
          no_edit_link = '%s: %s' % (capfirst(opts.verbose_name),
                                     force_text(obj))
  
          if has_admin:
              try:
                  admin_url = reverse('%s:%s_%s_change'
                                      % (admin_site.name,
                                         opts.app_label,
                                         opts.model_name),
                                      None, (quote(obj._get_pk_val()),))
              except NoReverseMatch:
                  # Change url doesn't exist -- don't display link to edit
                  return no_edit_link
  
              p = '%s.%s' % (opts.app_label,
                             get_permission_codename('delete', opts))
              if not user.has_perm(p):
                  perms_needed.add(opts.verbose_name)
              # Display a link to the admin page.
              return format_html('{}: <a href="{}">{}</a>',
                                 capfirst(opts.verbose_name),
                                 admin_url,
                                 obj)
          else:
              # Don't display link to edit, because it either has no
              # admin or is edited inline.
              return no_edit_link
  
      to_delete = collector.nested(format_callback)
  
      protected = [format_callback(obj) for obj in collector.protected]
      model_count = {model._meta.verbose_name_plural: len(objs) for model, objs in collector.model_objs.items()}
  
      return to_delete, model_count, perms_needed, protected
docs: Find all objects related to ``objs`` that should also be deleted. ``objs``
      must be a homogeneous iterable of objects (e.g. a QuerySet).
      Returns a nested list of strings suitable for display in the
      template with the ``unordered_list`` filter.