code: def auto_delete_files_on_instance_change(
          instance: Any,
          fieldnames: Iterable[str],
          model_class) -> None:
      
  
      if not instance.pk:
          return  # instance not yet saved in database
      # noinspection PyUnresolvedReferences
      try:
          # noinspection PyUnresolvedReferences
          old_instance = model_class.objects.get(pk=instance.pk)
      except model_class.DoesNotExist:
          return  # old version gone from database entirely
      for fieldname in fieldnames:
          old_filefield = getattr(old_instance, fieldname, None)
          if not old_filefield:
              continue
          new_filefield = getattr(instance, fieldname, None)
          if old_filefield != new_filefield:
              if os.path.isfile(old_filefield.path):
                  os.remove(old_filefield.path)
docs: Deletes files from filesystem when object is changed.
  
      model_class: ``Type[Model]``
  
      ... only the type checker in Py3.5 is broken; v.s.