def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
                 initial=None, error_class=ErrorList, label_suffix=':',
                 empty_permitted=False, instance=None,
                 collection=None):

        opts = self._meta
        if instance is None:
            # if we didn't get an instance, instantiate a new one
            if collection is None:
                raise TypeError("Collection must be supplied for an unbound "
                        "DocumentForm")
            self.instance = opts.document(collection=collection)
            object_data = {}
        else:
            self.instance = instance
            try:
                self.instance.collection
            except AttributeError:
                raise AssertionError("Instance must be bound to a collection.")

            object_data = document_to_dict(instance, opts.fields, opts.exclude)
        # if initial was provided, it should override the values from instance
        if initial is not None:
            object_data.update(initial)
        super(BaseDocumentForm, self).__init__(
            data, files, auto_id, prefix, object_data,
            error_class, label_suffix, empty_permitted
        )
dataset/ETHPy150Open peterbe/django-mongokit/django_mongokit/forms/forms.py/BaseDocumentForm.__init__/original