def __new__(cls, name, bases, attrs):
        formfield_callback = attrs.pop('formfield_callback', None)
        try:
            parents = [b for b in bases if issubclass(b, DocumentForm)]
        except __HOLE__:
            # We are defining ModelForm itself.
            parents = None
        declared_fields = get_declared_fields(bases, attrs, False)
        new_class = super(DocumentFormMetaclass, cls).__new__(cls, name, bases,
                attrs)
        if not parents:
            return new_class

        opts = new_class._meta = DocumentFormOptions(
            getattr(new_class, 'Meta', None)
        )
        if opts.document:
            # If a model is defined, extract form fields from it.
            fields = fields_for_document(opts.document, opts.fields,
                                      opts.exclude, formfield_callback)
            # Override default model fields with any custom declared ones
            # (plus, include all the other declared fields).
            fields.update(declared_fields)
        else:
            fields = declared_fields
        new_class.declared_fields = declared_fields
        new_class.base_fields = fields
        return new_class
dataset/ETHPy150Open peterbe/django-mongokit/django_mongokit/forms/forms.py/DocumentFormMetaclass.__new__