/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
from django.forms import ModelForm def create_modelform(model_, module=None): class _modelform(ModelForm): class Meta: model = model_ if module: _modelform.__module__ = module else: _modelform.__module__ = model_.__module__ _modelform.__name__ = '%sForm' % model_.__name__ return _modelform