

def document_to_dict(instance, fields=None, exclude=None):
    "\n    Returns a dict containing the data in ``instance`` suitable for passing as\n    a Form's ``initial`` keyword argument.\n\n    ``fields`` is an optional list of field names. If provided, only the named\n    fields will be included in the returned dict.\n\n    ``exclude`` is an optional list of field names. If provided, the named\n    fields will be excluded from the returned dict, even if they are listed in\n    the ``fields`` argument.\n    "
    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

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