def convert_to_id_fields(data, table, field_name):
 for item in data[table]:
  item[(field_name + '_id')] = item[field_name]
  del item[field_name]

def convert_to_id_fields ( data , table , field_name ) : for item in data [ table ] : item [ ( field_name + '_id' ) ] = item [ field_name ] del item [ field_name ]
when django gives us dict objects via model_to_dict .