def model_name_to_class(model_module, model_name):
 try:
  model_class_name = model_name.title()
  return getattr(model_module, model_class_name)
 except AttributeError:
  raise ValidationError(("%s isn't a valid model" % model_class_name))

def model_name_to_class ( model_module , model_name ) : try : model_class_name = model_name . title ( ) return getattr ( model_module , model_class_name ) except AttributeError : raise ValidationError ( ( "%s isn't a valid model" % model_class_name ) )
return the class in model_module that has the same name as the received string .