def document_to_dict(document, instance, properties=None, exclude=None, dotpath=None):
    """
    Returns a dict containing the data in ``instance`` suitable for passing as
    a Form's ``initial`` keyword argument.

    ``properties`` is an optional list of properties names. If provided, 
    only the named properties will be included in the returned dict.

    ``exclude`` is an optional list of properties names. If provided, the named
    properties will be excluded from the returned dict, even if they are listed 
    in the ``properties`` argument.
    """
    # avoid a circular import
    data = {}
    if dotpath:
        try:
            src_data = instance.dot_notation(dotpath)
        except DotPathNotFound:
            src_data = dict()
    else:
        src_data = instance
    
    if src_data is None:
        src_data = dict()
    
    for prop_name in src_data.keys():
        if properties and not prop_name in properties:
            continue
        if exclude and prop_name in exclude:
            continue
        if document._meta.fields in prop_name:
            prop = document._meta.fields[prop_name]
            if not properties and not prop.editable:
                continue
        data[prop_name] = src_data[prop_name]
    return data
dataset/ETHPy150Open zbyte64/django-dockit/dockit/forms/forms.py/document_to_dict/swapped operands of `in`