Posted By

logan on 03/07/11


Tagged

form model django


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

grzyweasel
saman


function creating modelform for django


 / Published in: Python
 

  1. from django.forms import ModelForm
  2.  
  3.  
  4. def create_modelform(model_, module=None):
  5. class _modelform(ModelForm):
  6. class Meta:
  7. model = model_
  8.  
  9. if module:
  10. _modelform.__module__ = module
  11. else:
  12. _modelform.__module__ = model_.__module__
  13. _modelform.__name__ = '%sForm' % model_.__name__
  14. return _modelform

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: god_of_nothing on March 9, 2011

hi i would be glad if you suggest on my codes.thanks!

You need to login to post a comment.