def form_for_model(model):
 parts = model.__module__.split('.')
 parts[parts.index('models')] = 'forms'
 module_name = '.'.join(parts)
 form_name = (model.__name__ + 'Form')
 module = try_import(module_name)
 if (module is not None):
  form = getattr(module, form_name, None)
  if (form is not None):
   return form
 meta_dict = LocationForm.Meta.__dict__
 meta_dict['model'] = model
 return type(form_name, (LocationForm,), {'Meta': type('Meta', (), meta_dict)})

def form_for_model ( model ) : parts = model . __module__ . split ( '.' ) parts [ parts . index ( 'models' ) ] = 'forms' module_name = '.' . join ( parts ) form_name = ( model . __name__ + 'Form' ) module = try_import ( module_name ) if ( module is not None ) : form = getattr ( module , form_name , None ) if ( form is not None ) : return form meta_dict = LocationForm . Meta . __dict__ meta_dict [ 'model' ] = model return type ( form_name , ( LocationForm , ) , { 'Meta' : type ( 'Meta' , ( ) , meta_dict ) } )
returns a form class for the given django model class .