def orm_item_locator(orm_obj):
 the_class = orm_obj._meta.object_name
 original_class = the_class
 pk_name = orm_obj._meta.pk.name
 original_pk_name = pk_name
 pk_value = getattr(orm_obj, pk_name)
 while (hasattr(pk_value, '_meta') and hasattr(pk_value._meta, 'pk') and hasattr(pk_value._meta.pk, 'name')):
  the_class = pk_value._meta.object_name
  pk_name = pk_value._meta.pk.name
  pk_value = getattr(pk_value, pk_name)
 clean_dict = make_clean_dict(orm_obj.__dict__)
 for key in clean_dict:
  v = clean_dict[key]
  if ((v is not None) and (not isinstance(v, (six.string_types, six.integer_types, float, datetime.datetime)))):
   clean_dict[key] = six.u(('%s' % v))
 output = (' importer.locate_object(%s, "%s", %s, "%s", %s, %s ) ' % (original_class, original_pk_name, the_class, pk_name, pk_value, clean_dict))
 return output

def orm_item_locator ( orm_obj ) : the_class = orm_obj . _meta . object_name original_class = the_class pk_name = orm_obj . _meta . pk . name original_pk_name = pk_name pk_value = getattr ( orm_obj , pk_name ) while ( hasattr ( pk_value , '_meta' ) and hasattr ( pk_value . _meta , 'pk' ) and hasattr ( pk_value . _meta . pk , 'name' ) ) : the_class = pk_value . _meta . object_name pk_name = pk_value . _meta . pk . name pk_value = getattr ( pk_value , pk_name ) clean_dict = make_clean_dict ( orm_obj . __dict__ ) for key in clean_dict : v = clean_dict [ key ] if ( ( v is not None ) and ( not isinstance ( v , ( six . string_types , six . integer_types , float , datetime . datetime ) ) ) ) : clean_dict [ key ] = six . u ( ( '%s' % v ) ) output = ( ' importer.locate_object(%s, "%s", %s, "%s", %s, %s ) ' % ( original_class , original_pk_name , the_class , pk_name , pk_value , clean_dict ) ) return output
this function is called every time an object that will not be exported is required .