

def documentform_factory(document, form=DocumentForm, fields=None, exclude=None, formfield_callback=None):
    try:
        document.collection
    except AttributeError:
        pass
    else:
        raise TypeError('Document must not be bound.')
    attrs = {
        'document': document,
    }
    if (fields is not None):
        attrs['fields'] = fields
    if (exclude is not None):
        attrs['exclude'] = exclude
    parent = (object,)
    if hasattr(form, 'Meta'):
        parent = (form.Meta, object)
    Meta = type('Meta', parent, attrs)
    class_name = ('%sForm' % document.__name__)
    form_class_attrs = {
        'Meta': Meta,
        'formfield_callback': formfield_callback,
    }
    return DocumentFormMetaclass(class_name, (form,), form_class_attrs)

dataset/ETHPy150Open peterbe/django-mongokit/django_mongokit/forms/forms.py documentform_factory/original