def addparentstofks(rels, fks):
 for j in rels:
  son = index(fks, j[1])
  parent = index(fks, j[0])
  fks[son][2] = fks[son][2].replace('models.Model', parent)
  if (parent not in fks[son][0]):
   fks[son][0].append(parent)

def addparentstofks ( rels , fks ) : for j in rels : son = index ( fks , j [ 1 ] ) parent = index ( fks , j [ 0 ] ) fks [ son ] [ 2 ] = fks [ son ] [ 2 ] . replace ( 'models.Model' , parent ) if ( parent not in fks [ son ] [ 0 ] ) : fks [ son ] [ 0 ] . append ( parent )
gets a list of relations .