Return to Snippet

Revision: 42571
at March 7, 2011 16:51 by logan


Initial Code
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

Initial URL

                                

Initial Description

                                

Initial Title
function creating modelform for django

Initial Tags
form, django

Initial Language
Python