def copy_model_instance(obj, exclude=None):
 exclude = (exclude or ())
 initial = dict(((f.name, getattr(obj, f.name)) for f in obj._meta.fields if ((not isinstance(f, AutoField)) and (f.name not in exclude) and (f not in obj._meta.parents.values()))))
 return obj.__class__(**initial)

def copy_model_instance ( obj , exclude = None ) : exclude = ( exclude or ( ) ) initial = dict ( ( ( f . name , getattr ( obj , f . name ) ) for f in obj . _meta . fields if ( ( not isinstance ( f , AutoField ) ) and ( f . name not in exclude ) and ( f not in obj . _meta . parents . values ( ) ) ) ) ) return obj . __class__ ( ** initial )
copy a model instance .