def delete_files_for_obj(sender, **kwargs):
 obj = kwargs.pop('instance')
 for field_name in sender._meta.get_all_field_names():
  if (not hasattr(obj, field_name)):
   continue
  try:
   field_class = sender._meta.get_field(field_name)
  except models.FieldDoesNotExist:
   continue
  field_value = getattr(obj, field_name)
  if (isinstance(field_class, models.FileField) and field_value):
   field_value.delete()

def delete_files_for_obj ( sender , ** kwargs ) : obj = kwargs . pop ( 'instance' ) for field_name in sender . _meta . get_all_field_names ( ) : if ( not hasattr ( obj , field_name ) ) : continue try : field_class = sender . _meta . get_field ( field_name ) except models . FieldDoesNotExist : continue field_value = getattr ( obj , field_name ) if ( isinstance ( field_class , models . FileField ) and field_value ) : field_value . delete ( )
signal receiver of a model class and instance .