def document_to_dict(instance, fields=None, exclude=None):
    # avoid a circular import
    structure = instance.structure

    data = {}
    for field_name in structure.keys():
        if fields and not field_name in fields:
            continue
        if exclude and field_name in exclude:
            continue
        data[field_name] = value_from_document(instance, field_name)

    return data
Returns a dict containing the data in ``instance`` suitable for passing as
dataset/ETHPy150Open peterbe/django-mongokit/django_mongokit/forms/forms.py/document_to_dict